aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2017-11-21 18:02:57 +0100
committerpracticalswift <practicalswift@users.noreply.github.com>2017-11-21 18:02:57 +0100
commit63f21d27ee463dafc32982d1ac50a1032449dd36 (patch)
tree9dcc4df50457b1ce4bbd2a80baa69c8e068245cd /src/net.cpp
parentd4267a3ab271d9affd3c1b0c2e30062490af804e (diff)
downloadbitcoin-63f21d27ee463dafc32982d1ac50a1032449dd36.tar.xz
net: Add missing locks in net.{cpp,h}
* writing variable 'nTotalBytesRecv' requires holding mutex 'cs_totalBytesRecv' exclusively * writing variables 'nTotalBytesSent'/'nMaxOutboundTotalBytesSentInCycle'/'nMaxOutboundCycleStartTime' require holding mutex 'cs_totalBytesSent' exclusively * writing variable 'nMaxOutboundTimeframe'/'nMaxOutboundLimit' require holding mutex 'cs_totalBytesSent' exclusively * writing variable 'vAddedNodes' requires holding mutex 'cs_vAddedNodes' exclusively
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp
index a8e5143d5e..12a0820a49 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2269,10 +2269,16 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
{
Init(connOptions);
- nTotalBytesRecv = 0;
- nTotalBytesSent = 0;
- nMaxOutboundTotalBytesSentInCycle = 0;
- nMaxOutboundCycleStartTime = 0;
+ {
+ LOCK(cs_totalBytesRecv);
+ nTotalBytesRecv = 0;
+ }
+ {
+ LOCK(cs_totalBytesSent);
+ nTotalBytesSent = 0;
+ nMaxOutboundTotalBytesSentInCycle = 0;
+ nMaxOutboundCycleStartTime = 0;
+ }
if (fListen && !InitBinds(connOptions.vBinds, connOptions.vWhiteBinds)) {
if (clientInterface) {