aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoind.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-01-19 15:33:55 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-01-19 15:37:48 +0100
commit28ee7e8b8c658bab4a5e13a13254950e226453a7 (patch)
tree2f2af0781de370ce41c05455d2a987e6038d3d76 /src/bitcoind.cpp
parente1aecae33a672b00fac31b6c3cc4c2f6a833ebfb (diff)
Get rid of DetectShutdownThread
The main thread spends time waiting for the DetectShutdownThread. So why not just run this waiting loop function in the main thread? One thread-stack less saves 4MB of virtual memory on 32-bit, and 8MB on 64-bit.
Diffstat (limited to 'src/bitcoind.cpp')
-rw-r--r--src/bitcoind.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 8a1745b50d..a0a96c2dfa 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -33,7 +33,7 @@
static bool fDaemon;
-void DetectShutdownThread(boost::thread_group* threadGroup)
+void WaitForShutdown(boost::thread_group* threadGroup)
{
bool fShutdown = ShutdownRequested();
// Tell the main threads to shutdown.
@@ -56,7 +56,6 @@ void DetectShutdownThread(boost::thread_group* threadGroup)
bool AppInit(int argc, char* argv[])
{
boost::thread_group threadGroup;
- boost::thread* detectShutdownThread = NULL;
bool fRet = false;
@@ -144,7 +143,6 @@ bool AppInit(int argc, char* argv[])
#endif
SoftSetBoolArg("-server", true);
- detectShutdownThread = new boost::thread(boost::bind(&DetectShutdownThread, &threadGroup));
fRet = AppInit2(threadGroup);
}
catch (const std::exception& e) {
@@ -155,20 +153,12 @@ bool AppInit(int argc, char* argv[])
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)
- {
- detectShutdownThread->join();
- delete detectShutdownThread;
- detectShutdownThread = NULL;
+ } else {
+ WaitForShutdown(&threadGroup);
}
Shutdown();