diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-07-26 11:11:25 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-07-26 11:11:42 +0200 |
commit | 9dd6a2be4188866a147a6043ec54439339091b59 (patch) | |
tree | 85c5ce308312beea79111b3a07097a5e54994191 | |
parent | 5c003cb1afcb959ace2579ba0d764525f5bfacaf (diff) | |
parent | a2420ae2f1e0fd9a257a0a506ff40a4dca842474 (diff) |
Merge #10824: Avoid unnecessary work in SetNetworkActive
a2420ae Avoid unnecessary work in SetNetworkActive (João Barbosa)
Pull request description:
This PR adds an early return to avoid unnecessary notifications when the status doesn't change.
Tree-SHA512: 85d05ca6fa36cb581f94bc154d08bd72cd53f6a857173c6fb2f184058f9c0208c4cf5e5d196825a78339902d8f256688eb6793f99abc7be9c7cfac85136180d9
-rw-r--r-- | src/net.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp index 0994af3021..f82be75186 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2183,16 +2183,18 @@ void CConnman::SetNetworkActive(bool active) { LogPrint(BCLog::NET, "SetNetworkActive: %s\n", active); - if (!active) { - fNetworkActive = false; + if (fNetworkActive == active) { + return; + } + + fNetworkActive = active; + if (!fNetworkActive) { LOCK(cs_vNodes); // Close sockets to all nodes for (CNode* pnode : vNodes) { pnode->CloseSocketDisconnect(); } - } else { - fNetworkActive = true; } uiInterface.NotifyNetworkActiveChanged(fNetworkActive); |