Port Bitcoin PR#13131 to fig Windows SIGTERM bug
This commit is contained in:
46
src/init.cpp
46
src/init.cpp
@@ -56,7 +56,6 @@
|
|||||||
#include "wallet/wallet.h"
|
#include "wallet/wallet.h"
|
||||||
#include "wallet/walletdb.h"
|
#include "wallet/walletdb.h"
|
||||||
#include "wallet/asyncrpcoperation_saplingconsolidation.h"
|
#include "wallet/asyncrpcoperation_saplingconsolidation.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -291,6 +290,7 @@ void Shutdown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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, so:
|
||||||
|
#ifndef WIN32
|
||||||
void HandleSIGTERM(int)
|
void HandleSIGTERM(int)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s\n",__FUNCTION__);
|
fprintf(stderr,"%s\n",__FUNCTION__);
|
||||||
@@ -302,6 +302,26 @@ void HandleSIGHUP(int)
|
|||||||
fprintf(stderr,"%s\n",__FUNCTION__);
|
fprintf(stderr,"%s\n",__FUNCTION__);
|
||||||
fReopenDebugLog = true;
|
fReopenDebugLog = true;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
|
||||||
|
{
|
||||||
|
fRequestShutdown = true;
|
||||||
|
// This signal now sleeps with the fishes
|
||||||
|
Sleep(INFINITE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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, nullptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool static InitError(const std::string &str)
|
bool static InitError(const std::string &str)
|
||||||
{
|
{
|
||||||
@@ -356,7 +376,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||||||
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), 288));
|
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), 288));
|
||||||
strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), 3));
|
strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), 3));
|
||||||
strUsage += HelpMessageOpt("-clientname=<SomeName>", _("Full node client name, default 'MagicBean'"));
|
strUsage += HelpMessageOpt("-clientname=<SomeName>", _("Full node client name, default 'MagicBean'"));
|
||||||
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "komodo.conf"));
|
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "HUSH3.conf"));
|
||||||
if (mode == HMM_BITCOIND)
|
if (mode == HMM_BITCOIND)
|
||||||
{
|
{
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
@@ -979,21 +999,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
umask(077);
|
umask(077);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik1\n", __FUNCTION__);
|
|
||||||
// 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, NULL);
|
|
||||||
sigaction(SIGINT, &sa, NULL);
|
|
||||||
|
|
||||||
// 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, NULL);
|
|
||||||
|
|
||||||
// Ignore SIGPIPE, otherwise it will bring the daemon down if the client closes unexpectedly
|
// Ignore SIGPIPE, otherwise it will bring the daemon down if the client closes unexpectedly
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
@@ -1487,8 +1499,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
std::string warningString;
|
std::string warningString;
|
||||||
std::string errorString;
|
std::string errorString;
|
||||||
|
|
||||||
if (!CWallet::Verify(strWalletFile, warningString, errorString))
|
if (!CWallet::Verify(strWalletFile, warningString, errorString)) {
|
||||||
|
uiInterface.InitMessage(_("Verification failed!"));
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!warningString.empty())
|
if (!warningString.empty())
|
||||||
InitWarning(warningString);
|
InitWarning(warningString);
|
||||||
@@ -1510,7 +1524,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
return InitError(strprintf("User Agent comment (%s) contains unsafe characters.", cmt));
|
return InitError(strprintf("User Agent comment (%s) contains unsafe characters.", cmt));
|
||||||
uacomments.push_back(SanitizeString(cmt, SAFE_CHARS_UA_COMMENT));
|
uacomments.push_back(SanitizeString(cmt, SAFE_CHARS_UA_COMMENT));
|
||||||
}
|
}
|
||||||
strSubVersion = FormatSubVersion(GetArg("-clientname","MagicBean"), CLIENT_VERSION, uacomments);
|
strSubVersion = FormatSubVersion(GetArg("-clientname","jl777sRemorse"), CLIENT_VERSION, uacomments);
|
||||||
if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
|
if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
|
||||||
return InitError(strprintf("Total length of network version string %i exceeds maximum of %i characters. Reduce the number and/or size of uacomments.",
|
return InitError(strprintf("Total length of network version string %i exceeds maximum of %i characters. Reduce the number and/or size of uacomments.",
|
||||||
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
|
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
|
||||||
|
|||||||
Reference in New Issue
Block a user