@@ -886,7 +886,7 @@ static void RelayAddress(const CAddress& addr, bool fReachable, CConnman& connma
886
886
connman.ForEachNodeThen (std::move (sortfunc), std::move (pushfunc));
887
887
}
888
888
889
- void static ProcessGetData (CNode* pfrom, const Consensus::Params& consensusParams, CConnman& connman)
889
+ void static ProcessGetData (CNode* pfrom, const Consensus::Params& consensusParams, CConnman& connman, std::atomic< bool >& interruptMsgProc )
890
890
{
891
891
std::deque<CInv>::iterator it = pfrom->vRecvGetData .begin ();
892
892
unsigned int nMaxSendBufferSize = connman.GetSendBufferSize ();
@@ -901,7 +901,9 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
901
901
902
902
const CInv &inv = *it;
903
903
{
904
- boost::this_thread::interruption_point ();
904
+ if (interruptMsgProc)
905
+ return ;
906
+
905
907
it++;
906
908
907
909
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || inv.type == MSG_CMPCT_BLOCK || inv.type == MSG_WITNESS_BLOCK)
@@ -1055,7 +1057,7 @@ uint32_t GetFetchFlags(CNode* pfrom, CBlockIndex* pprev, const Consensus::Params
1055
1057
return nFetchFlags;
1056
1058
}
1057
1059
1058
- bool static ProcessMessage (CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman& connman)
1060
+ bool static ProcessMessage (CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman& connman, std::atomic< bool >& interruptMsgProc )
1059
1061
{
1060
1062
unsigned int nMaxSendBufferSize = connman.GetSendBufferSize ();
1061
1063
@@ -1295,7 +1297,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1295
1297
int64_t nSince = nNow - 10 * 60 ;
1296
1298
BOOST_FOREACH (CAddress& addr, vAddr)
1297
1299
{
1298
- boost::this_thread::interruption_point ();
1300
+ if (interruptMsgProc)
1301
+ return true ;
1299
1302
1300
1303
if ((addr.nServices & REQUIRED_SERVICES) != REQUIRED_SERVICES)
1301
1304
continue ;
@@ -1377,7 +1380,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1377
1380
{
1378
1381
CInv &inv = vInv[nInv];
1379
1382
1380
- boost::this_thread::interruption_point ();
1383
+ if (interruptMsgProc)
1384
+ return true ;
1381
1385
1382
1386
bool fAlreadyHave = AlreadyHave (inv);
1383
1387
LogPrint (" net" , " got inv: %s %s peer=%d\n " , inv.ToString (), fAlreadyHave ? " have" : " new" , pfrom->id );
@@ -1439,7 +1443,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1439
1443
LogPrint (" net" , " received getdata for: %s peer=%d\n " , vInv[0 ].ToString (), pfrom->id );
1440
1444
1441
1445
pfrom->vRecvGetData .insert (pfrom->vRecvGetData .end (), vInv.begin (), vInv.end ());
1442
- ProcessGetData (pfrom, chainparams.GetConsensus (), connman);
1446
+ ProcessGetData (pfrom, chainparams.GetConsensus (), connman, interruptMsgProc );
1443
1447
}
1444
1448
1445
1449
@@ -1513,7 +1517,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1513
1517
inv.type = State (pfrom->GetId ())->fWantsCmpctWitness ? MSG_WITNESS_BLOCK : MSG_BLOCK;
1514
1518
inv.hash = req.blockhash ;
1515
1519
pfrom->vRecvGetData .push_back (inv);
1516
- ProcessGetData (pfrom, chainparams.GetConsensus (), connman);
1520
+ ProcessGetData (pfrom, chainparams.GetConsensus (), connman, interruptMsgProc );
1517
1521
return true ;
1518
1522
}
1519
1523
@@ -1925,10 +1929,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1925
1929
} // cs_main
1926
1930
1927
1931
if (fProcessBLOCKTXN )
1928
- return ProcessMessage (pfrom, NetMsgType::BLOCKTXN, blockTxnMsg, nTimeReceived, chainparams, connman);
1932
+ return ProcessMessage (pfrom, NetMsgType::BLOCKTXN, blockTxnMsg, nTimeReceived, chainparams, connman, interruptMsgProc );
1929
1933
1930
1934
if (fRevertToHeaderProcessing )
1931
- return ProcessMessage (pfrom, NetMsgType::HEADERS, vHeadersMsg, nTimeReceived, chainparams, connman);
1935
+ return ProcessMessage (pfrom, NetMsgType::HEADERS, vHeadersMsg, nTimeReceived, chainparams, connman, interruptMsgProc );
1932
1936
1933
1937
if (fBlockReconstructed ) {
1934
1938
// If we got here, we were able to optimistically reconstruct a
@@ -2441,7 +2445,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
2441
2445
}
2442
2446
2443
2447
// requires LOCK(cs_vRecvMsg)
2444
- bool ProcessMessages (CNode* pfrom, CConnman& connman)
2448
+ bool ProcessMessages (CNode* pfrom, CConnman& connman, std::atomic< bool >& interruptMsgProc )
2445
2449
{
2446
2450
const CChainParams& chainparams = Params ();
2447
2451
unsigned int nMaxSendBufferSize = connman.GetSendBufferSize ();
@@ -2459,7 +2463,7 @@ bool ProcessMessages(CNode* pfrom, CConnman& connman)
2459
2463
bool fOk = true ;
2460
2464
2461
2465
if (!pfrom->vRecvGetData .empty ())
2462
- ProcessGetData (pfrom, chainparams.GetConsensus (), connman);
2466
+ ProcessGetData (pfrom, chainparams.GetConsensus (), connman, interruptMsgProc );
2463
2467
2464
2468
// this maintains the order of responses
2465
2469
if (!pfrom->vRecvGetData .empty ()) return fOk ;
@@ -2520,8 +2524,9 @@ bool ProcessMessages(CNode* pfrom, CConnman& connman)
2520
2524
bool fRet = false ;
2521
2525
try
2522
2526
{
2523
- fRet = ProcessMessage (pfrom, strCommand, vRecv, msg.nTime , chainparams, connman);
2524
- boost::this_thread::interruption_point ();
2527
+ fRet = ProcessMessage (pfrom, strCommand, vRecv, msg.nTime , chainparams, connman, interruptMsgProc);
2528
+ if (interruptMsgProc)
2529
+ return true ;
2525
2530
}
2526
2531
catch (const std::ios_base::failure& e)
2527
2532
{
@@ -2585,7 +2590,7 @@ class CompareInvMempoolOrder
2585
2590
}
2586
2591
};
2587
2592
2588
- bool SendMessages (CNode* pto, CConnman& connman)
2593
+ bool SendMessages (CNode* pto, CConnman& connman, std::atomic< bool >& interruptMsgProc )
2589
2594
{
2590
2595
const Consensus::Params& consensusParams = Params ().GetConsensus ();
2591
2596
{
0 commit comments