From 06b00e93ae3b9c0653a0eedbb8783498e3bacc14 Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Tue, 18 Jun 2019 15:43:14 -0700 Subject: [PATCH] Limit the stats-dump on packet error --- libraries/networking/src/LimitedNodeList.cpp | 17 ++++++++++------- libraries/networking/src/LimitedNodeList.h | 3 +++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 8fefe5820c..4282e05542 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -450,13 +450,16 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const HifiS auto size = sendUnreliablePacket(*packet, sockAddr, hmacAuth); if (size < 0) { auto now = usecTimestampNow(); - eachNode([now](const SharedNodePointer & node) { - qCDebug(networking) << "Stats for " << node->getPublicSocket() << "\n" - << " Last Heard Microstamp: " << node->getLastHeardMicrostamp() << " (" << (now - node->getLastHeardMicrostamp()) << "usec ago)\n" - << " Outbound Kbps: " << node->getOutboundKbps() << "\n" - << " Inbound Kbps: " << node->getInboundKbps() << "\n" - << " Ping: " << node->getPingMs(); - }); + if (now - _sendErrorStatsTime > ERROR_STATS_PERIOD_US) { + _sendErrorStatsTime = now; + eachNode([now](const SharedNodePointer& node) { + qCDebug(networking) << "Stats for " << node->getPublicSocket() << "\n" + << " Last Heard Microstamp: " << node->getLastHeardMicrostamp() << " (" << (now - node->getLastHeardMicrostamp()) << "usec ago)\n" + << " Outbound Kbps: " << node->getOutboundKbps() << "\n" + << " Inbound Kbps: " << node->getInboundKbps() << "\n" + << " Ping: " << node->getPingMs(); + }); + } } return size; } diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index f9f6bf3b3e..7e40d763e4 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -497,6 +497,9 @@ private: float _outboundKbps { 0.0f }; bool _dropOutgoingNodeTraffic { false }; + + quint64 _sendErrorStatsTime { (quint64)0 }; + static const quint64 ERROR_STATS_PERIOD_US { 2 * USECS_PER_SECOND }; }; #endif // hifi_LimitedNodeList_h