Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | #endif | ||||
GetMainSignals().UnregisterWithMempoolSignals(g_mempool); | GetMainSignals().UnregisterWithMempoolSignals(g_mempool); | ||||
g_wallet_init_interface->Close(); | g_wallet_init_interface->Close(); | ||||
globalVerifyHandle.reset(); | globalVerifyHandle.reset(); | ||||
ECC_Stop(); | ECC_Stop(); | ||||
LogPrintf("%s: done\n", __func__); | LogPrintf("%s: done\n", __func__); | ||||
} | } | ||||
/** | /** | ||||
* Signal handlers are very limited in what they are allowed to do, so: | * Signal handlers are very limited in what they are allowed to do. | ||||
* The execution context the handler is invoked in is not guaranteed, | |||||
* so we restrict handler operations to just touching variables: | |||||
*/ | */ | ||||
void HandleSIGTERM(int) { | static void HandleSIGTERM(int) { | ||||
fRequestShutdown = true; | fRequestShutdown = true; | ||||
} | } | ||||
void HandleSIGHUP(int) { | static void HandleSIGHUP(int) { | ||||
GetLogger().m_reopen_file = true; | GetLogger().m_reopen_file = true; | ||||
} | } | ||||
#ifndef WIN32 | |||||
static void registerSignalHandler(int signal, void (*handler)(int)) { | |||||
struct sigaction sa; | |||||
sa.sa_handler = handler; | |||||
sigemptyset(&sa.sa_mask); | |||||
sa.sa_flags = 0; | |||||
sigaction(signal, &sa, NULL); | |||||
} | |||||
#endif | |||||
void OnRPCStarted() { | void OnRPCStarted() { | ||||
uiInterface.NotifyBlockTip.connect(&RPCNotifyBlockChange); | uiInterface.NotifyBlockTip.connect(&RPCNotifyBlockChange); | ||||
} | } | ||||
void OnRPCStopped() { | void OnRPCStopped() { | ||||
uiInterface.NotifyBlockTip.disconnect(&RPCNotifyBlockChange); | uiInterface.NotifyBlockTip.disconnect(&RPCNotifyBlockChange); | ||||
RPCNotifyBlockChange(false, nullptr); | RPCNotifyBlockChange(false, nullptr); | ||||
g_best_block_cv.notify_all(); | g_best_block_cv.notify_all(); | ||||
▲ Show 20 Lines • Show All 1,028 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
#ifndef WIN32 | #ifndef WIN32 | ||||
if (!gArgs.GetBoolArg("-sysperms", false)) { | if (!gArgs.GetBoolArg("-sysperms", false)) { | ||||
umask(077); | umask(077); | ||||
} | } | ||||
// Clean shutdown on SIGTERM | // Clean shutdown on SIGTERM | ||||
struct sigaction sa; | registerSignalHandler(SIGTERM, HandleSIGTERM); | ||||
sa.sa_handler = HandleSIGTERM; | registerSignalHandler(SIGINT, HandleSIGTERM); | ||||
sigemptyset(&sa.sa_mask); | |||||
sa.sa_flags = 0; | |||||
sigaction(SIGTERM, &sa, nullptr); | |||||
sigaction(SIGINT, &sa, nullptr); | |||||
// Reopen debug.log on SIGHUP | // Reopen debug.log on SIGHUP | ||||
struct sigaction sa_hup; | registerSignalHandler(SIGHUP, HandleSIGHUP); | ||||
sa_hup.sa_handler = HandleSIGHUP; | |||||
sigemptyset(&sa_hup.sa_mask); | |||||
sa_hup.sa_flags = 0; | |||||
sigaction(SIGHUP, &sa_hup, nullptr); | |||||
// Ignore SIGPIPE, otherwise it will bring the daemon down if the client | // Ignore SIGPIPE, otherwise it will bring the daemon down if the client | ||||
// closes unexpectedly | // closes unexpectedly | ||||
signal(SIGPIPE, SIG_IGN); | signal(SIGPIPE, SIG_IGN); | ||||
#endif | #endif | ||||
std::set_new_handler(new_handler_terminate); | std::set_new_handler(new_handler_terminate); | ||||
▲ Show 20 Lines • Show All 1,017 Lines • Show Last 20 Lines |