mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-12 12:52:35 -03:00
*Always* send a shutdown signal to enable custom shutdown actions
NOTE: This is required to be sure that we can properly shut down the RPC thread. Signed-off-by: Giel van Schijndel <me@mortis.eu>
This commit is contained in:
parent
07368a9e3c
commit
896899e0d6
2 changed files with 7 additions and 7 deletions
|
@ -2884,8 +2884,7 @@ void ThreadRPCServer2(void* parg)
|
||||||
}
|
}
|
||||||
|
|
||||||
vnThreadsRunning[THREAD_RPCLISTENER]--;
|
vnThreadsRunning[THREAD_RPCLISTENER]--;
|
||||||
while (!fShutdown)
|
io_service.run();
|
||||||
io_service.run_one();
|
|
||||||
vnThreadsRunning[THREAD_RPCLISTENER]++;
|
vnThreadsRunning[THREAD_RPCLISTENER]++;
|
||||||
|
|
||||||
// Terminate all outstanding accept-requests
|
// Terminate all outstanding accept-requests
|
||||||
|
|
11
src/init.cpp
11
src/init.cpp
|
@ -9,6 +9,7 @@
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
|
#include <boost/bind.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <boost/filesystem/convenience.hpp>
|
#include <boost/filesystem/convenience.hpp>
|
||||||
|
@ -40,13 +41,8 @@ void ExitTimeout(void* parg)
|
||||||
|
|
||||||
void StartShutdown()
|
void StartShutdown()
|
||||||
{
|
{
|
||||||
#ifdef QT_GUI
|
|
||||||
// ensure we leave the Qt main loop for a clean GUI exit (Shutdown() is called in bitcoin.cpp afterwards)
|
// ensure we leave the Qt main loop for a clean GUI exit (Shutdown() is called in bitcoin.cpp afterwards)
|
||||||
uiInterface.QueueShutdown();
|
uiInterface.QueueShutdown();
|
||||||
#else
|
|
||||||
// Without UI, Shutdown() can simply be started in a new thread
|
|
||||||
CreateThread(Shutdown, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown(void* parg)
|
void Shutdown(void* parg)
|
||||||
|
@ -154,6 +150,11 @@ bool AppInit(int argc, char* argv[])
|
||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the shutdown thread when receiving a shutdown signal
|
||||||
|
boost::signals2::scoped_connection do_stop(
|
||||||
|
uiInterface.QueueShutdown.connect(boost::bind(
|
||||||
|
&CreateThread, &Shutdown, static_cast<void*>(0), false)));
|
||||||
|
|
||||||
fRet = AppInit2();
|
fRet = AppInit2();
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
|
|
Loading…
Reference in a new issue