diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-07-09 16:40:37 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-07-09 16:50:09 +0200 |
commit | 172f984f598f471f970d2ed4bf6379e9aa33901e (patch) | |
tree | bc02068002380534527778580461766a2e74f602 | |
parent | b55f0c31d461e9f7d3769adc4f06d1a1bb637086 (diff) | |
parent | 4b6ab02122d225818f6c6a4b4ef343d2c90e6d55 (diff) |
Merge #13615: net: Remove unused interrupt from SendMessages
4b6ab02122d225818f6c6a4b4ef343d2c90e6d55 Remove unused argument to ProcessGetBlockData(...) (practicalswift)
c469ecf22e8ab55acf2cf8fc6fcf34415b541f76 net: Remove unused interrupt from SendMessages (fanquake)
Pull request description:
Discussed very briefly with cfields.
Includes 65b4400 from #13554 as it's a similar refactor.
Tree-SHA512: 45cd64208a5c8164242db74e6687e9344ea592bab5e7f9ba8e1bb449057fc908ec9d8b8523748a68426e4a4304e3388a138cd834698b39837b2149b72beefdc9
-rw-r--r-- | src/net.cpp | 2 | ||||
-rw-r--r-- | src/net.h | 2 | ||||
-rw-r--r-- | src/net_processing.cpp | 6 | ||||
-rw-r--r-- | src/net_processing.h | 10 | ||||
-rw-r--r-- | src/test/denialofservice_tests.cpp | 24 |
5 files changed, 22 insertions, 22 deletions
diff --git a/src/net.cpp b/src/net.cpp index 55043ffe30..b24ceb67d6 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2042,7 +2042,7 @@ void CConnman::ThreadMessageHandler() // Send messages { LOCK(pnode->cs_sendProcessing); - m_msgproc->SendMessages(pnode, flagInterruptMsgProc); + m_msgproc->SendMessages(pnode); } if (flagInterruptMsgProc) @@ -466,7 +466,7 @@ class NetEventsInterface { public: virtual bool ProcessMessages(CNode* pnode, std::atomic<bool>& interrupt) = 0; - virtual bool SendMessages(CNode* pnode, std::atomic<bool>& interrupt) = 0; + virtual bool SendMessages(CNode* pnode) = 0; virtual void InitializeNode(CNode* pnode) = 0; virtual void FinalizeNode(NodeId id, bool& update_connection_time) = 0; diff --git a/src/net_processing.cpp b/src/net_processing.cpp index ed9debc95a..458e9c2e9f 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1070,7 +1070,7 @@ static void RelayAddress(const CAddress& addr, bool fReachable, CConnman* connma connman->ForEachNodeThen(std::move(sortfunc), std::move(pushfunc)); } -void static ProcessGetBlockData(CNode* pfrom, const CChainParams& chainparams, const CInv& inv, CConnman* connman, const std::atomic<bool>& interruptMsgProc) +void static ProcessGetBlockData(CNode* pfrom, const CChainParams& chainparams, const CInv& inv, CConnman* connman) { bool send = false; std::shared_ptr<const CBlock> a_recent_block; @@ -1274,7 +1274,7 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm const CInv &inv = *it; if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || inv.type == MSG_CMPCT_BLOCK || inv.type == MSG_WITNESS_BLOCK) { it++; - ProcessGetBlockData(pfrom, chainparams, inv, connman, interruptMsgProc); + ProcessGetBlockData(pfrom, chainparams, inv, connman); } } @@ -3218,7 +3218,7 @@ public: } }; -bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& interruptMsgProc) +bool PeerLogicValidation::SendMessages(CNode* pto) { const Consensus::Params& consensusParams = Params().GetConsensus(); { diff --git a/src/net_processing.h b/src/net_processing.h index 3bdb4785a2..0d97b316eb 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -68,16 +68,20 @@ public: void InitializeNode(CNode* pnode) override; /** Handle removal of a peer by updating various state and removing it from mapNodeState */ void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) override; - /** Process protocol messages received from a given node */ + /** + * Process protocol messages received from a given node + * + * @param[in] pfrom The node which we have received messages from. + * @param[in] interrupt Interrupt condition for processing threads + */ bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override; /** * Send queued protocol messages to be sent to a give node. * * @param[in] pto The node which we are sending messages to. - * @param[in] interrupt Interrupt condition for processing threads * @return True if there is more work to be done */ - bool SendMessages(CNode* pto, std::atomic<bool>& interrupt) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing); + bool SendMessages(CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing); /** Consider evicting an outbound peer based on the amount of time they've been behind our tip */ void ConsiderEviction(CNode *pto, int64_t time_in_seconds); diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp index bebbd6c464..cc871726fd 100644 --- a/src/test/denialofservice_tests.cpp +++ b/src/test/denialofservice_tests.cpp @@ -54,7 +54,6 @@ BOOST_FIXTURE_TEST_SUITE(denialofservice_tests, TestingSetup) // work. BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction) { - std::atomic<bool> interruptDummy(false); // Mock an outbound peer CAddress addr1(ip(0xa0b0c001), NODE_NONE); @@ -75,7 +74,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction) // Test starts here { LOCK2(cs_main, dummyNode1.cs_sendProcessing); - peerLogic->SendMessages(&dummyNode1, interruptDummy); // should result in getheaders + peerLogic->SendMessages(&dummyNode1); // should result in getheaders } { LOCK2(cs_main, dummyNode1.cs_vSend); @@ -88,7 +87,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction) SetMockTime(nStartTime+21*60); { LOCK2(cs_main, dummyNode1.cs_sendProcessing); - peerLogic->SendMessages(&dummyNode1, interruptDummy); // should result in getheaders + peerLogic->SendMessages(&dummyNode1); // should result in getheaders } { LOCK2(cs_main, dummyNode1.cs_vSend); @@ -98,7 +97,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction) SetMockTime(nStartTime+24*60); { LOCK2(cs_main, dummyNode1.cs_sendProcessing); - peerLogic->SendMessages(&dummyNode1, interruptDummy); // should result in disconnect + peerLogic->SendMessages(&dummyNode1); // should result in disconnect } BOOST_CHECK(dummyNode1.fDisconnect == true); SetMockTime(0); @@ -192,7 +191,6 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management) BOOST_AUTO_TEST_CASE(DoS_banning) { - std::atomic<bool> interruptDummy(false); connman->ClearBanned(); CAddress addr1(ip(0xa0b0c001), NODE_NONE); @@ -207,7 +205,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning) } { LOCK2(cs_main, dummyNode1.cs_sendProcessing); - peerLogic->SendMessages(&dummyNode1, interruptDummy); + peerLogic->SendMessages(&dummyNode1); } BOOST_CHECK(connman->IsBanned(addr1)); BOOST_CHECK(!connman->IsBanned(ip(0xa0b0c001|0x0000ff00))); // Different IP, not banned @@ -224,7 +222,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning) } { LOCK2(cs_main, dummyNode2.cs_sendProcessing); - peerLogic->SendMessages(&dummyNode2, interruptDummy); + peerLogic->SendMessages(&dummyNode2); } BOOST_CHECK(!connman->IsBanned(addr2)); // 2 not banned yet... BOOST_CHECK(connman->IsBanned(addr1)); // ... but 1 still should be @@ -234,7 +232,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning) } { LOCK2(cs_main, dummyNode2.cs_sendProcessing); - peerLogic->SendMessages(&dummyNode2, interruptDummy); + peerLogic->SendMessages(&dummyNode2); } BOOST_CHECK(connman->IsBanned(addr2)); @@ -245,7 +243,6 @@ BOOST_AUTO_TEST_CASE(DoS_banning) BOOST_AUTO_TEST_CASE(DoS_banscore) { - std::atomic<bool> interruptDummy(false); connman->ClearBanned(); gArgs.ForceSetArg("-banscore", "111"); // because 11 is my favorite number @@ -261,7 +258,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore) } { LOCK2(cs_main, dummyNode1.cs_sendProcessing); - peerLogic->SendMessages(&dummyNode1, interruptDummy); + peerLogic->SendMessages(&dummyNode1); } BOOST_CHECK(!connman->IsBanned(addr1)); { @@ -270,7 +267,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore) } { LOCK2(cs_main, dummyNode1.cs_sendProcessing); - peerLogic->SendMessages(&dummyNode1, interruptDummy); + peerLogic->SendMessages(&dummyNode1); } BOOST_CHECK(!connman->IsBanned(addr1)); { @@ -279,7 +276,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore) } { LOCK2(cs_main, dummyNode1.cs_sendProcessing); - peerLogic->SendMessages(&dummyNode1, interruptDummy); + peerLogic->SendMessages(&dummyNode1); } BOOST_CHECK(connman->IsBanned(addr1)); gArgs.ForceSetArg("-banscore", std::to_string(DEFAULT_BANSCORE_THRESHOLD)); @@ -290,7 +287,6 @@ BOOST_AUTO_TEST_CASE(DoS_banscore) BOOST_AUTO_TEST_CASE(DoS_bantime) { - std::atomic<bool> interruptDummy(false); connman->ClearBanned(); int64_t nStartTime = GetTime(); @@ -309,7 +305,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime) } { LOCK2(cs_main, dummyNode.cs_sendProcessing); - peerLogic->SendMessages(&dummyNode, interruptDummy); + peerLogic->SendMessages(&dummyNode); } BOOST_CHECK(connman->IsBanned(addr)); |