diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bitcoind.cpp | 17 | ||||
-rw-r--r-- | src/main.cpp | 10 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 02e4e7d6e7..407e1d28c7 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -9,15 +9,18 @@ void DetectShutdownThread(boost::thread_group* threadGroup) { - bool shutdown = ShutdownRequested(); + bool fShutdown = ShutdownRequested(); // Tell the main threads to shutdown. - while (!shutdown) + while (!fShutdown) { MilliSleep(200); - shutdown = ShutdownRequested(); + fShutdown = ShutdownRequested(); } if (threadGroup) + { threadGroup->interrupt_all(); + threadGroup->join_all(); + } } ////////////////////////////////////////////////////////////////////////////// @@ -107,10 +110,16 @@ bool AppInit(int argc, char* argv[]) } catch (...) { PrintExceptionContinue(NULL, "AppInit()"); } - if (!fRet) { + + if (!fRet) + { if (detectShutdownThread) detectShutdownThread->interrupt(); + threadGroup.interrupt_all(); + // threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of + // the startup-failure cases to make sure they don't result in a hang due to some + // thread-blocking-waiting-for-another-thread-during-startup case } if (detectShutdownThread) diff --git a/src/main.cpp b/src/main.cpp index dcf0ee01ae..ed40a3550a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3786,8 +3786,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted); } int nDoS = 0; - if (state.IsInvalid(nDoS) && nDoS > 0) - pfrom->Misbehaving(nDoS); + if (state.IsInvalid(nDoS)) + if (nDoS > 0) + pfrom->Misbehaving(nDoS); } @@ -3806,8 +3807,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (ProcessBlock(state, pfrom, &block)) mapAlreadyAskedFor.erase(inv); int nDoS = 0; - if (state.IsInvalid(nDoS) && nDoS > 0) - pfrom->Misbehaving(nDoS); + if (state.IsInvalid(nDoS)) + if (nDoS > 0) + pfrom->Misbehaving(nDoS); } |