3333
3434static bool fDaemon ;
3535
36- void DetectShutdownThread (boost::thread_group* threadGroup)
36+ void WaitForShutdown (boost::thread_group* threadGroup)
3737{
3838 bool fShutdown = ShutdownRequested ();
3939 // Tell the main threads to shutdown.
@@ -56,7 +56,6 @@ void DetectShutdownThread(boost::thread_group* threadGroup)
5656bool AppInit (int argc, char * argv[])
5757{
5858 boost::thread_group threadGroup;
59- boost::thread* detectShutdownThread = NULL ;
6059
6160 bool fRet = false ;
6261
@@ -144,7 +143,6 @@ bool AppInit(int argc, char* argv[])
144143#endif
145144 SoftSetBoolArg (" -server" , true );
146145
147- detectShutdownThread = new boost::thread (boost::bind (&DetectShutdownThread, &threadGroup));
148146 fRet = AppInit2 (threadGroup);
149147 }
150148 catch (const std::exception& e) {
@@ -155,20 +153,12 @@ bool AppInit(int argc, char* argv[])
155153
156154 if (!fRet )
157155 {
158- if (detectShutdownThread)
159- detectShutdownThread->interrupt ();
160-
161156 threadGroup.interrupt_all ();
162157 // threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of
163158 // the startup-failure cases to make sure they don't result in a hang due to some
164159 // thread-blocking-waiting-for-another-thread-during-startup case
165- }
166-
167- if (detectShutdownThread)
168- {
169- detectShutdownThread->join ();
170- delete detectShutdownThread;
171- detectShutdownThread = NULL ;
160+ } else {
161+ WaitForShutdown (&threadGroup);
172162 }
173163 Shutdown ();
174164
0 commit comments