aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoind.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-10-07 15:42:07 -0700
committerGavin Andresen <gavinandresen@gmail.com>2013-10-07 15:42:07 -0700
commitaa56d317a57467cabc28008831b0398485e73f6a (patch)
treed5cd3b20e3a99a5a258f7218617e5a190bbb8aee /src/bitcoind.cpp
parent5fc1700fb031e1016157715f7a244ccc5b775762 (diff)
parentc55d1600da35e3882f149b00f972c0ef9cb41dfa (diff)
downloadbitcoin-aa56d317a57467cabc28008831b0398485e73f6a.tar.xz
Merge pull request #3059 from Diapolo/Shutdown
add missing Boost Thread join_all() call during shutdown
Diffstat (limited to 'src/bitcoind.cpp')
-rw-r--r--src/bitcoind.cpp17
1 files changed, 13 insertions, 4 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)