Skip to content

Commit 9d09132

Browse files
committed
CConnman: initialise at declaration rather than in Start()
Ensure nMaxOutboundTotalBytesSentInCycle and nMaxOutboundCycleStartTime are initialized even if CConnman::Start() is not called.
1 parent e7986c5 commit 9d09132

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

src/net.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,17 +2445,6 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
24452445
{
24462446
Init(connOptions);
24472447

2448-
{
2449-
LOCK(cs_totalBytesRecv);
2450-
nTotalBytesRecv = 0;
2451-
}
2452-
{
2453-
LOCK(cs_totalBytesSent);
2454-
nTotalBytesSent = 0;
2455-
nMaxOutboundTotalBytesSentInCycle = 0;
2456-
nMaxOutboundCycleStartTime = 0;
2457-
}
2458-
24592448
if (fListen && !InitBinds(connOptions.vBinds, connOptions.vWhiteBinds, connOptions.onion_binds)) {
24602449
if (clientInterface) {
24612450
clientInterface->ThreadSafeMessageBox(

src/net.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,8 @@ class CConnman
478478
uint64_t nTotalBytesSent GUARDED_BY(cs_totalBytesSent) {0};
479479

480480
// outbound limit & stats
481-
uint64_t nMaxOutboundTotalBytesSentInCycle GUARDED_BY(cs_totalBytesSent);
482-
uint64_t nMaxOutboundCycleStartTime GUARDED_BY(cs_totalBytesSent);
481+
uint64_t nMaxOutboundTotalBytesSentInCycle GUARDED_BY(cs_totalBytesSent) {0};
482+
uint64_t nMaxOutboundCycleStartTime GUARDED_BY(cs_totalBytesSent) {0};
483483
uint64_t nMaxOutboundLimit GUARDED_BY(cs_totalBytesSent);
484484
uint64_t nMaxOutboundTimeframe GUARDED_BY(cs_totalBytesSent);
485485

0 commit comments

Comments
 (0)