From 9ed3312438560fc55ded41fc46d69c37f5c9872a Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Tue, 15 Apr 2025 12:43:00 -0400 Subject: [PATCH] properly mutex lock in AffiliationLookup; add more mutex locking in ChannelLookup; --- src/common/lookups/AffiliationLookup.cpp | 10 +++++++++- src/common/lookups/ChannelLookup.cpp | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/lookups/AffiliationLookup.cpp b/src/common/lookups/AffiliationLookup.cpp index e8b784df..5859b985 100644 --- a/src/common/lookups/AffiliationLookup.cpp +++ b/src/common/lookups/AffiliationLookup.cpp @@ -299,11 +299,12 @@ bool AffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTi return false; } + std::lock_guard lock(m_mutex); + if (!m_chLookup->isRFChAvailable()) { return false; } - std::lock_guard lock(m_mutex); uint32_t chNo = m_chLookup->getFirstRFChannel(); if (!m_chLookup->removeRFCh(chNo)) { return false; @@ -336,6 +337,7 @@ void AffiliationLookup::touchGrant(uint32_t dstId) } std::lock_guard lock(m_mutex); + if (isGranted(dstId)) { m_grantTimers[dstId].start(); } @@ -431,6 +433,8 @@ bool AffiliationLookup::isChBusy(uint32_t chNo) const bool AffiliationLookup::isGranted(uint32_t dstId) const { + std::lock_guard lock(m_mutex); + if (dstId == 0U) { return false; } @@ -453,6 +457,8 @@ bool AffiliationLookup::isGranted(uint32_t dstId) const bool AffiliationLookup::isGroup(uint32_t dstId) const { + std::lock_guard lock(m_mutex); + if (dstId == 0U) { return true; } @@ -470,6 +476,8 @@ bool AffiliationLookup::isGroup(uint32_t dstId) const bool AffiliationLookup::isNetGranted(uint32_t dstId) const { + std::lock_guard lock(m_mutex); + if (dstId == 0U) { return false; } diff --git a/src/common/lookups/ChannelLookup.cpp b/src/common/lookups/ChannelLookup.cpp index 2845c1d0..fed733be 100644 --- a/src/common/lookups/ChannelLookup.cpp +++ b/src/common/lookups/ChannelLookup.cpp @@ -39,6 +39,8 @@ ChannelLookup::~ChannelLookup() = default; VoiceChData ChannelLookup::getRFChData(uint32_t chNo) const { + std::lock_guard lock(m_mutex); + if (chNo == 0U) { return VoiceChData(); } @@ -58,6 +60,7 @@ VoiceChData ChannelLookup::getRFChData(uint32_t chNo) const bool ChannelLookup::addRFCh(uint32_t chNo, bool force) { std::lock_guard lock(m_mutex); + if (chNo == 0U) { return false; } @@ -81,6 +84,7 @@ bool ChannelLookup::addRFCh(uint32_t chNo, bool force) bool ChannelLookup::removeRFCh(uint32_t chNo) { std::lock_guard lock(m_mutex); + if (chNo == 0U) { return false; }