Skip to content

Commit dc10100

Browse files
furszyFuzzbawls
authored andcommitted
[bugfix] Making tier two thread interruptable.
1 parent 2ae76aa commit dc10100

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

src/masternodeman.cpp

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "swifttx.h"
1818
#include "util.h"
1919

20+
#include <boost/thread/thread.hpp>
2021

2122
#define MN_WINNER_MINIMUM_AGE 8000 // Age in seconds. This should be > MASTERNODE_REMOVAL_SECONDS to avoid misconfigured new nodes in the list.
2223

@@ -868,24 +869,33 @@ void ThreadCheckMasternodes()
868869

869870
unsigned int c = 0;
870871

871-
while (true) {
872-
MilliSleep(1000);
872+
try {
873+
while (true) {
873874

874-
// try to sync from all available nodes, one step at a time
875-
masternodeSync.Process();
875+
if (ShutdownRequested()) {
876+
break;
877+
}
876878

877-
if (masternodeSync.IsBlockchainSynced()) {
878-
c++;
879+
MilliSleep(1000);
880+
boost::this_thread::interruption_point();
881+
// try to sync from all available nodes, one step at a time
882+
masternodeSync.Process();
879883

880-
// check if we should activate or ping every few minutes,
881-
// start right after sync is considered to be done
882-
if (c % MASTERNODE_PING_SECONDS == 1) activeMasternode.ManageStatus();
884+
if (masternodeSync.IsBlockchainSynced()) {
885+
c++;
883886

884-
if (c % 60 == 0) {
885-
mnodeman.CheckAndRemove();
886-
masternodePayments.CleanPaymentList();
887-
CleanTransactionLocksList();
887+
// check if we should activate or ping every few minutes,
888+
// start right after sync is considered to be done
889+
if (c % MASTERNODE_PING_SECONDS == 1) activeMasternode.ManageStatus();
890+
891+
if (c % 60 == 0) {
892+
mnodeman.CheckAndRemove();
893+
masternodePayments.CleanPaymentList();
894+
CleanTransactionLocksList();
895+
}
888896
}
889897
}
898+
} catch (boost::thread_interrupted&) {
899+
// nothing, thread interrupted.
890900
}
891901
}

0 commit comments

Comments
 (0)