Skip to content

Commit aa56d31

Browse files
committed
Merge pull request #3059 from Diapolo/Shutdown
add missing Boost Thread join_all() call during shutdown
2 parents 5fc1700 + c55d160 commit aa56d31

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/bitcoind.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99

1010
void DetectShutdownThread(boost::thread_group* threadGroup)
1111
{
12-
bool shutdown = ShutdownRequested();
12+
bool fShutdown = ShutdownRequested();
1313
// Tell the main threads to shutdown.
14-
while (!shutdown)
14+
while (!fShutdown)
1515
{
1616
MilliSleep(200);
17-
shutdown = ShutdownRequested();
17+
fShutdown = ShutdownRequested();
1818
}
1919
if (threadGroup)
20+
{
2021
threadGroup->interrupt_all();
22+
threadGroup->join_all();
23+
}
2124
}
2225

2326
//////////////////////////////////////////////////////////////////////////////
@@ -107,10 +110,16 @@ bool AppInit(int argc, char* argv[])
107110
} catch (...) {
108111
PrintExceptionContinue(NULL, "AppInit()");
109112
}
110-
if (!fRet) {
113+
114+
if (!fRet)
115+
{
111116
if (detectShutdownThread)
112117
detectShutdownThread->interrupt();
118+
113119
threadGroup.interrupt_all();
120+
// threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of
121+
// the startup-failure cases to make sure they don't result in a hang due to some
122+
// thread-blocking-waiting-for-another-thread-during-startup case
114123
}
115124

116125
if (detectShutdownThread)

0 commit comments

Comments
 (0)