From b6b9724cb4cebff2f6c7e89fc546ab0e5077aff8 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Mon, 9 Nov 2026 16:20:40 -0500 Subject: [PATCH] silence excess log noise; --- src/common/lookups/AffiliationLookup.cpp | 20 ++++++-------- src/common/lookups/AffiliationLookup.h | 6 ++-- src/fne/lookups/AffiliationLookup.cpp | 8 +++--- src/fne/lookups/AffiliationLookup.h | 6 ++-- src/fne/network/TrafficNetwork.cpp | 35 ++++++++++++++++-------- src/fne/network/TrafficNetwork.h | 6 ++-- 6 files changed, 47 insertions(+), 34 deletions(-) diff --git a/src/common/lookups/AffiliationLookup.cpp b/src/common/lookups/AffiliationLookup.cpp index b9fc640c..109cbd9d 100644 --- a/src/common/lookups/AffiliationLookup.cpp +++ b/src/common/lookups/AffiliationLookup.cpp @@ -65,7 +65,7 @@ AffiliationLookup::~AffiliationLookup() = default; /* Helper to group affiliate a source ID. */ -void AffiliationLookup::unitReg(uint32_t srcId) +void AffiliationLookup::unitReg(uint32_t srcId, bool log) { if (isUnitReg(srcId)) { return; @@ -78,9 +78,8 @@ void AffiliationLookup::unitReg(uint32_t srcId) m_unitRegTimers[srcId] = Timer(1000U, UNIT_REG_TIMEOUT); m_unitRegTimers[srcId].start(); - if (m_verbose) { - LogInfoEx(LOG_HOST, "%s, unit registration, srcId = %u", - m_name.c_str(), srcId); + if (m_verbose && log) { + LogInfoEx(LOG_HOST, "%s, unit registration, srcId = %u", m_name.c_str(), srcId); } __unlock(); @@ -88,7 +87,7 @@ void AffiliationLookup::unitReg(uint32_t srcId) /* Helper to group unaffiliate a source ID. */ -bool AffiliationLookup::unitDereg(uint32_t srcId, bool automatic) +bool AffiliationLookup::unitDereg(uint32_t srcId, bool automatic, bool log) { bool ret = false; @@ -100,9 +99,8 @@ bool AffiliationLookup::unitDereg(uint32_t srcId, bool automatic) __lock(); - if (m_verbose) { - LogInfoEx(LOG_HOST, "%s, unit deregistration, srcId = %u", - m_name.c_str(), srcId); + if (m_verbose && log) { + LogInfoEx(LOG_HOST, "%s, unit deregistration, srcId = %u", m_name.c_str(), srcId); } m_unitRegTimers[srcId].stop(); @@ -254,8 +252,7 @@ void AffiliationLookup::groupAff(uint32_t srcId, uint32_t dstId) m_grpAffTimers[srcId].start(); if (m_verbose) { - LogInfoEx(LOG_HOST, "%s, group affiliation, srcId = %u, dstId = %u", - m_name.c_str(), srcId, dstId); + LogInfoEx(LOG_HOST, "%s, group affiliation, srcId = %u, dstId = %u", m_name.c_str(), srcId, dstId); } __unlock(); @@ -272,8 +269,7 @@ bool AffiliationLookup::groupUnaff(uint32_t srcId) auto it = m_grpAffTable.find(srcId); if (it != m_grpAffTable.end()) { if (m_verbose) { - LogInfoEx(LOG_HOST, "%s, group unaffiliation, srcId = %u, dstId = %u", - m_name.c_str(), srcId, it->second); + LogInfoEx(LOG_HOST, "%s, group unaffiliation, srcId = %u, dstId = %u", m_name.c_str(), srcId, it->second); } m_grpAffTable.erase(srcId); diff --git a/src/common/lookups/AffiliationLookup.h b/src/common/lookups/AffiliationLookup.h index 325a4c35..3e45a224 100644 --- a/src/common/lookups/AffiliationLookup.h +++ b/src/common/lookups/AffiliationLookup.h @@ -71,15 +71,17 @@ namespace lookups /** * @brief Helper to register a source ID. * @param srcId Source Radio ID. + * @param log Flag indicating whether the registration should be logged. */ - virtual void unitReg(uint32_t srcId); + virtual void unitReg(uint32_t srcId, bool log = true); /** * @brief Helper to deregister a source ID. * @param srcId Source Radio ID. * @param automatic Flag indicating the deregistration is a result of an automated timer. + * @param log Flag indicating whether the deregistration should be logged. * @returns bool True, if source ID is deregistered, otherwise false. */ - virtual bool unitDereg(uint32_t srcId, bool automatic = false); + virtual bool unitDereg(uint32_t srcId, bool automatic = false, bool log = true); /** * @brief Helper to start the source ID registration timer. * @param srcId Source Radio ID. diff --git a/src/fne/lookups/AffiliationLookup.cpp b/src/fne/lookups/AffiliationLookup.cpp index 03ad7bff..22f226de 100644 --- a/src/fne/lookups/AffiliationLookup.cpp +++ b/src/fne/lookups/AffiliationLookup.cpp @@ -31,21 +31,21 @@ AffiliationLookup::~AffiliationLookup() = default; /* Helper to group affiliate a source ID. */ -void AffiliationLookup::unitReg(uint32_t srcId, uint32_t ssrc) +void AffiliationLookup::unitReg(uint32_t srcId, uint32_t ssrc, bool log) { if (isUnitReg(srcId)) { m_unitRegPeerTable[srcId] = ssrc; return; } - ::lookups::AffiliationLookup::unitReg(srcId); + ::lookups::AffiliationLookup::unitReg(srcId, log); m_unitRegPeerTable[srcId] = ssrc; } /* Helper to group unaffiliate a source ID. */ -bool AffiliationLookup::unitDereg(uint32_t srcId, bool automatic) +bool AffiliationLookup::unitDereg(uint32_t srcId, bool automatic, bool log) { bool ret = false; @@ -53,7 +53,7 @@ bool AffiliationLookup::unitDereg(uint32_t srcId, bool automatic) return false; } - ret = ::lookups::AffiliationLookup::unitDereg(srcId, automatic); + ret = ::lookups::AffiliationLookup::unitDereg(srcId, automatic, log); if (ret) { // lookup dynamic table entry diff --git a/src/fne/lookups/AffiliationLookup.h b/src/fne/lookups/AffiliationLookup.h index c793d8ab..902a2a5e 100644 --- a/src/fne/lookups/AffiliationLookup.h +++ b/src/fne/lookups/AffiliationLookup.h @@ -60,15 +60,17 @@ namespace fne_lookups * @brief Helper to register a source ID. * @param srcId Source Radio ID. * @param ssrc Originating Peer ID. + * @param log Flag indicating whether the registration should be logged. */ - void unitReg(uint32_t srcId, uint32_t ssrc); + void unitReg(uint32_t srcId, uint32_t ssrc, bool log = true); /** * @brief Helper to deregister a source ID. * @param srcId Source Radio ID. * @param automatic Flag indicating the deregistration is a result of an automated timer. + * @param log Flag indicating whether the deregistration should be logged. * @returns bool True, if source ID is deregistered, otherwise false. */ - bool unitDereg(uint32_t srcId, bool automatic = false) override; + bool unitDereg(uint32_t srcId, bool automatic = false, bool log = true) override; /** * @brief Helper to get the originating network peer ID by the registered source ID. * @param srcId Source Radio ID. diff --git a/src/fne/network/TrafficNetwork.cpp b/src/fne/network/TrafficNetwork.cpp index 361ebc3c..4ea011dc 100644 --- a/src/fne/network/TrafficNetwork.cpp +++ b/src/fne/network/TrafficNetwork.cpp @@ -981,7 +981,7 @@ void TrafficNetwork::clock(uint32_t ms) const std::vector expiredRoutes = m_unitRouteRegistry.expire(now); for (const UnitRoute& route : expiredRoutes) { LogInfoEx(LOG_MASTER, "Private call route expired, srcId = %u, peerId = %u", route.unitId, route.peerId); - removePeerUnitRegistration(route.peerId, route.unitId); + removePeerUnitRegistration(route.peerId, route.unitId, false); } MetricsLogging::resetActiveCalls(); @@ -1640,7 +1640,7 @@ void TrafficNetwork::learnUnitRouteFromTraffic(uint32_t peerId, uint32_t srcId, // update the peer unit registration const UnitRoute current = m_unitRouteRegistry.resolve(srcId, now); if (!current.valid || current.peerId != peerId) { - updatePeerUnitRegistration(peerId, srcId, ssrc); + updatePeerUnitRegistration(peerId, srcId, ssrc, false); } m_unitRouteRegistry.update(srcId, peerId, ssrc, true, now); @@ -1833,6 +1833,7 @@ bool TrafficNetwork::updatePeerAffiliation(uint32_t peerId, uint32_t srcId, uint affiliations->groupUnaff(srcId); affiliations->groupAff(srcId, dstId); + aggregate = buildAggregatedAffiliations(); } @@ -1854,6 +1855,7 @@ bool TrafficNetwork::removePeerAffiliation(uint32_t peerId, uint32_t srcId) return false; affiliations->groupUnaff(srcId); + aggregate = buildAggregatedAffiliations(); } @@ -1875,6 +1877,7 @@ bool TrafficNetwork::replacePeerAffiliations(uint32_t peerId, const std::unorder return false; peerAffiliations->replaceGroupAffiliations(affiliations); + aggregate = buildAggregatedAffiliations(); } @@ -1901,12 +1904,12 @@ std::unordered_map TrafficNetwork::buildAggregatedAffiliatio const std::unordered_map affiliations = peer.second->grpAffTable(); for (const auto& affiliation : affiliations) { const auto result = aggregate.emplace(affiliation.first, affiliation.second); - /* +/* if (!result.second && result.first->second != affiliation.second) { LogWarning(LOG_MASTER, "PEER %u affiliation conflict, srcId = %u, dstId = %u already represented by dstId = %u from a lower peer ID", peer.first, affiliation.first, affiliation.second, result.first->second); } - */ +*/ } } @@ -1926,7 +1929,7 @@ void TrafficNetwork::publishAggregatedAffiliations(const std::unordered_map aggregate; @@ -1942,10 +1945,11 @@ bool TrafficNetwork::updatePeerUnitRegistration(uint32_t peerId, uint32_t srcId, if (registrations == nullptr) return false; - registrations->unitReg(srcId, ssrc); - const uint64_t now = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()).count(); + registrations->unitReg(srcId, ssrc, log); + + const uint64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); m_unitRouteRegistry.update(srcId, peerId, ssrc, false, now); + aggregate = buildAggregatedUnitRegistrations(); } @@ -1955,7 +1959,7 @@ bool TrafficNetwork::updatePeerUnitRegistration(uint32_t peerId, uint32_t srcId, /* Removes one peer unit registration and publishes the aggregate upstream. */ -bool TrafficNetwork::removePeerUnitRegistration(uint32_t peerId, uint32_t srcId) +bool TrafficNetwork::removePeerUnitRegistration(uint32_t peerId, uint32_t srcId, bool log) { std::vector aggregate; std::unordered_map aggregateAffiliations; @@ -1967,8 +1971,10 @@ bool TrafficNetwork::removePeerUnitRegistration(uint32_t peerId, uint32_t srcId) if (registrations == nullptr) return false; - registrations->unitDereg(srcId); + registrations->unitDereg(srcId, false, log); + m_unitRouteRegistry.erase(srcId, peerId); + aggregate = buildAggregatedUnitRegistrations(); aggregateAffiliations = buildAggregatedAffiliations(); } @@ -1998,8 +2004,10 @@ bool TrafficNetwork::replacePeerUnitRegistrations(uint32_t peerId, const std::ve registrationOrigins[srcId] = ssrc; peerRegistrations->replaceUnitRegistrations(registrationOrigins); + const uint64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); m_unitRouteRegistry.replacePeer(peerId, registrations, ssrc, now); + aggregate = buildAggregatedUnitRegistrations(); } @@ -2026,21 +2034,24 @@ std::vector TrafficNetwork::buildAggregatedUnitRegistrations() for (const uint32_t srcId : registrations) { const uint32_t ssrc = peer.second->getSSRCByUnitReg(srcId); const auto result = aggregateOrigins.emplace(srcId, ssrc); - /* +/* if (!result.second && result.first->second != ssrc) { LogWarning(LOG_MASTER, "PEER %u unit registration conflict, srcId = %u already represented by lower peer ID", peer.first, srcId); } - */ +*/ } } m_globalAff->replaceUnitRegistrations(aggregateOrigins); + // build the aggregate list of unit registrations from the origins map std::vector aggregate; aggregate.reserve(aggregateOrigins.size()); for (const auto& registration : aggregateOrigins) aggregate.push_back(registration.first); + std::sort(aggregate.begin(), aggregate.end()); + return aggregate; } diff --git a/src/fne/network/TrafficNetwork.h b/src/fne/network/TrafficNetwork.h index cfb67d3e..cd31306e 100644 --- a/src/fne/network/TrafficNetwork.h +++ b/src/fne/network/TrafficNetwork.h @@ -863,16 +863,18 @@ namespace network * @param peerId Peer ID. * @param srcId Source Radio ID. * @param ssrc Originating peer ID. + * @param log Flag indicating whether the registration should be logged. * @returns bool True, if the peer affiliation lookup exists, otherwise false. */ - bool updatePeerUnitRegistration(uint32_t peerId, uint32_t srcId, uint32_t ssrc); + bool updatePeerUnitRegistration(uint32_t peerId, uint32_t srcId, uint32_t ssrc, bool log = true); /** * @brief Removes one peer unit registration and publishes the aggregate upstream. * @param peerId Peer ID. * @param srcId Source Radio ID. + * @param log Flag indicating whether the deregistration should be logged. * @returns bool True, if the peer affiliation lookup exists, otherwise false. */ - bool removePeerUnitRegistration(uint32_t peerId, uint32_t srcId); + bool removePeerUnitRegistration(uint32_t peerId, uint32_t srcId, bool log = true); /** * @brief Replaces one peer's unit registrations and publishes the aggregate upstream. * @param peerId Peer ID.