Skip to content

Commit 172f984

Browse files
committed
Merge #13615: net: Remove unused interrupt from SendMessages
4b6ab02 Remove unused argument to ProcessGetBlockData(...) (practicalswift) c469ecf 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
2 parents b55f0c3 + 4b6ab02 commit 172f984

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,7 @@ void CConnman::ThreadMessageHandler()
20422042
// Send messages
20432043
{
20442044
LOCK(pnode->cs_sendProcessing);
2045-
m_msgproc->SendMessages(pnode, flagInterruptMsgProc);
2045+
m_msgproc->SendMessages(pnode);
20462046
}
20472047

20482048
if (flagInterruptMsgProc)

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class NetEventsInterface
466466
{
467467
public:
468468
virtual bool ProcessMessages(CNode* pnode, std::atomic<bool>& interrupt) = 0;
469-
virtual bool SendMessages(CNode* pnode, std::atomic<bool>& interrupt) = 0;
469+
virtual bool SendMessages(CNode* pnode) = 0;
470470
virtual void InitializeNode(CNode* pnode) = 0;
471471
virtual void FinalizeNode(NodeId id, bool& update_connection_time) = 0;
472472

src/net_processing.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ static void RelayAddress(const CAddress& addr, bool fReachable, CConnman* connma
10701070
connman->ForEachNodeThen(std::move(sortfunc), std::move(pushfunc));
10711071
}
10721072

1073-
void static ProcessGetBlockData(CNode* pfrom, const CChainParams& chainparams, const CInv& inv, CConnman* connman, const std::atomic<bool>& interruptMsgProc)
1073+
void static ProcessGetBlockData(CNode* pfrom, const CChainParams& chainparams, const CInv& inv, CConnman* connman)
10741074
{
10751075
bool send = false;
10761076
std::shared_ptr<const CBlock> a_recent_block;
@@ -1274,7 +1274,7 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
12741274
const CInv &inv = *it;
12751275
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || inv.type == MSG_CMPCT_BLOCK || inv.type == MSG_WITNESS_BLOCK) {
12761276
it++;
1277-
ProcessGetBlockData(pfrom, chainparams, inv, connman, interruptMsgProc);
1277+
ProcessGetBlockData(pfrom, chainparams, inv, connman);
12781278
}
12791279
}
12801280

@@ -3218,7 +3218,7 @@ class CompareInvMempoolOrder
32183218
}
32193219
};
32203220

3221-
bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& interruptMsgProc)
3221+
bool PeerLogicValidation::SendMessages(CNode* pto)
32223222
{
32233223
const Consensus::Params& consensusParams = Params().GetConsensus();
32243224
{

src/net_processing.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,20 @@ class PeerLogicValidation final : public CValidationInterface, public NetEventsI
6868
void InitializeNode(CNode* pnode) override;
6969
/** Handle removal of a peer by updating various state and removing it from mapNodeState */
7070
void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) override;
71-
/** Process protocol messages received from a given node */
71+
/**
72+
* Process protocol messages received from a given node
73+
*
74+
* @param[in] pfrom The node which we have received messages from.
75+
* @param[in] interrupt Interrupt condition for processing threads
76+
*/
7277
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override;
7378
/**
7479
* Send queued protocol messages to be sent to a give node.
7580
*
7681
* @param[in] pto The node which we are sending messages to.
77-
* @param[in] interrupt Interrupt condition for processing threads
7882
* @return True if there is more work to be done
7983
*/
80-
bool SendMessages(CNode* pto, std::atomic<bool>& interrupt) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing);
84+
bool SendMessages(CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing);
8185

8286
/** Consider evicting an outbound peer based on the amount of time they've been behind our tip */
8387
void ConsiderEviction(CNode *pto, int64_t time_in_seconds);

src/test/denialofservice_tests.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ BOOST_FIXTURE_TEST_SUITE(denialofservice_tests, TestingSetup)
5454
// work.
5555
BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
5656
{
57-
std::atomic<bool> interruptDummy(false);
5857

5958
// Mock an outbound peer
6059
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
@@ -75,7 +74,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
7574
// Test starts here
7675
{
7776
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
78-
peerLogic->SendMessages(&dummyNode1, interruptDummy); // should result in getheaders
77+
peerLogic->SendMessages(&dummyNode1); // should result in getheaders
7978
}
8079
{
8180
LOCK2(cs_main, dummyNode1.cs_vSend);
@@ -88,7 +87,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
8887
SetMockTime(nStartTime+21*60);
8988
{
9089
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
91-
peerLogic->SendMessages(&dummyNode1, interruptDummy); // should result in getheaders
90+
peerLogic->SendMessages(&dummyNode1); // should result in getheaders
9291
}
9392
{
9493
LOCK2(cs_main, dummyNode1.cs_vSend);
@@ -98,7 +97,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
9897
SetMockTime(nStartTime+24*60);
9998
{
10099
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
101-
peerLogic->SendMessages(&dummyNode1, interruptDummy); // should result in disconnect
100+
peerLogic->SendMessages(&dummyNode1); // should result in disconnect
102101
}
103102
BOOST_CHECK(dummyNode1.fDisconnect == true);
104103
SetMockTime(0);
@@ -192,7 +191,6 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
192191

193192
BOOST_AUTO_TEST_CASE(DoS_banning)
194193
{
195-
std::atomic<bool> interruptDummy(false);
196194

197195
connman->ClearBanned();
198196
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
@@ -207,7 +205,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
207205
}
208206
{
209207
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
210-
peerLogic->SendMessages(&dummyNode1, interruptDummy);
208+
peerLogic->SendMessages(&dummyNode1);
211209
}
212210
BOOST_CHECK(connman->IsBanned(addr1));
213211
BOOST_CHECK(!connman->IsBanned(ip(0xa0b0c001|0x0000ff00))); // Different IP, not banned
@@ -224,7 +222,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
224222
}
225223
{
226224
LOCK2(cs_main, dummyNode2.cs_sendProcessing);
227-
peerLogic->SendMessages(&dummyNode2, interruptDummy);
225+
peerLogic->SendMessages(&dummyNode2);
228226
}
229227
BOOST_CHECK(!connman->IsBanned(addr2)); // 2 not banned yet...
230228
BOOST_CHECK(connman->IsBanned(addr1)); // ... but 1 still should be
@@ -234,7 +232,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
234232
}
235233
{
236234
LOCK2(cs_main, dummyNode2.cs_sendProcessing);
237-
peerLogic->SendMessages(&dummyNode2, interruptDummy);
235+
peerLogic->SendMessages(&dummyNode2);
238236
}
239237
BOOST_CHECK(connman->IsBanned(addr2));
240238

@@ -245,7 +243,6 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
245243

246244
BOOST_AUTO_TEST_CASE(DoS_banscore)
247245
{
248-
std::atomic<bool> interruptDummy(false);
249246

250247
connman->ClearBanned();
251248
gArgs.ForceSetArg("-banscore", "111"); // because 11 is my favorite number
@@ -261,7 +258,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
261258
}
262259
{
263260
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
264-
peerLogic->SendMessages(&dummyNode1, interruptDummy);
261+
peerLogic->SendMessages(&dummyNode1);
265262
}
266263
BOOST_CHECK(!connman->IsBanned(addr1));
267264
{
@@ -270,7 +267,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
270267
}
271268
{
272269
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
273-
peerLogic->SendMessages(&dummyNode1, interruptDummy);
270+
peerLogic->SendMessages(&dummyNode1);
274271
}
275272
BOOST_CHECK(!connman->IsBanned(addr1));
276273
{
@@ -279,7 +276,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
279276
}
280277
{
281278
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
282-
peerLogic->SendMessages(&dummyNode1, interruptDummy);
279+
peerLogic->SendMessages(&dummyNode1);
283280
}
284281
BOOST_CHECK(connman->IsBanned(addr1));
285282
gArgs.ForceSetArg("-banscore", std::to_string(DEFAULT_BANSCORE_THRESHOLD));
@@ -290,7 +287,6 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
290287

291288
BOOST_AUTO_TEST_CASE(DoS_bantime)
292289
{
293-
std::atomic<bool> interruptDummy(false);
294290

295291
connman->ClearBanned();
296292
int64_t nStartTime = GetTime();
@@ -309,7 +305,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
309305
}
310306
{
311307
LOCK2(cs_main, dummyNode.cs_sendProcessing);
312-
peerLogic->SendMessages(&dummyNode, interruptDummy);
308+
peerLogic->SendMessages(&dummyNode);
313309
}
314310
BOOST_CHECK(connman->IsBanned(addr));
315311

0 commit comments

Comments
 (0)