From 9d09132be4ff99f98ca905c342347d5f35f13350 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Tue, 17 Nov 2020 22:56:21 +1000 Subject: [PATCH] CConnman: initialise at declaration rather than in Start() Ensure nMaxOutboundTotalBytesSentInCycle and nMaxOutboundCycleStartTime are initialized even if CConnman::Start() is not called. --- src/net.cpp | 11 ----------- src/net.h | 4 ++-- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index cf987b6995..20c1763ea6 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2445,17 +2445,6 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions) { Init(connOptions); - { - LOCK(cs_totalBytesRecv); - nTotalBytesRecv = 0; - } - { - LOCK(cs_totalBytesSent); - nTotalBytesSent = 0; - nMaxOutboundTotalBytesSentInCycle = 0; - nMaxOutboundCycleStartTime = 0; - } - if (fListen && !InitBinds(connOptions.vBinds, connOptions.vWhiteBinds, connOptions.onion_binds)) { if (clientInterface) { clientInterface->ThreadSafeMessageBox( diff --git a/src/net.h b/src/net.h index 77649247d9..a6dcf7f610 100644 --- a/src/net.h +++ b/src/net.h @@ -478,8 +478,8 @@ private: uint64_t nTotalBytesSent GUARDED_BY(cs_totalBytesSent) {0}; // outbound limit & stats - uint64_t nMaxOutboundTotalBytesSentInCycle GUARDED_BY(cs_totalBytesSent); - uint64_t nMaxOutboundCycleStartTime GUARDED_BY(cs_totalBytesSent); + uint64_t nMaxOutboundTotalBytesSentInCycle GUARDED_BY(cs_totalBytesSent) {0}; + uint64_t nMaxOutboundCycleStartTime GUARDED_BY(cs_totalBytesSent) {0}; uint64_t nMaxOutboundLimit GUARDED_BY(cs_totalBytesSent); uint64_t nMaxOutboundTimeframe GUARDED_BY(cs_totalBytesSent);