From 181be5b3da7b04143822791e83ada06ad7240e19 Mon Sep 17 00:00:00 2001 From: FireMartZ Date: Fri, 16 Feb 2018 11:17:45 -0500 Subject: [PATCH] Add 15 seconds hard cap on shutdown wait. --- src/init.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 508f41666..e878110e2 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -294,6 +294,8 @@ void HandleSIGHUP(int) #ifdef WIN32 BOOL CtrlHandler( DWORD fdwCtrlType ) { + int64_t nMaxWait = 15; // seconds + int64_t nStart = GetTime(); switch( fdwCtrlType ) { case CTRL_C_EVENT: @@ -302,8 +304,8 @@ BOOL CtrlHandler( DWORD fdwCtrlType ) case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: fRequestShutdown = true; - std::cout << _("Shutting down node. This may take a while, be patient!") << std::endl; - while (!fShutdownCompleted) + std::cout << _("Shutting down node. This may take a while, be patient!") << std::endl; + while (!fShutdownCompleted && (GetTime() - nStart < nMaxWait)) { MilliSleep(100); }