Skip to content

Commit 5bcae79

Browse files
committed
Merge #20408: CConnman: move initialization to declaration
9d09132 CConnman: initialise at declaration rather than in Start() (Anthony Towns) Pull request description: Ensure nMaxOutboundTotalBytesSentInCycle and nMaxOutboundCycleStartTime are initialized even if CConnman::Start() is not called. Prevents failures in test/fuzz/connman when run under valgrind. ACKs for top commit: practicalswift: ACK 9d09132: patch looks correct! MarcoFalke: review ACK 9d09132 , checked that we call Start only once and in the same scope where connman is constructed (AppInitMain) 💸 jnewbery: Code review ACK 9d09132 Tree-SHA512: 1c6c893e8c616a91947a8cc295b0ba508af3ecfcdcd94cdc5f95d808cc93c6d1a71fd24dcc194dc583854e9889fb522ca8523043367fb0263370fbcab08c6aaa
2 parents a64ff1c + 9d09132 commit 5bcae79

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)