summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-06-25 20:46:30 +0200
committerGitHub <noreply@github.com>2018-06-25 20:46:30 +0200
commita70955368115603b5c9856ecb24e25430293d1b7 (patch)
treeeff1b4ae55ae03f82846e7176f2bbc9e59f0876d /src
parentce52b50c244e9223c398b70575616e88414446ce (diff)
parent9852b6ac5eea101aa71d80b01a41d46cb4add5d1 (diff)
downloadhercules-a70955368115603b5c9856ecb24e25430293d1b7.tar.gz
hercules-a70955368115603b5c9856ecb24e25430293d1b7.tar.bz2
hercules-a70955368115603b5c9856ecb24e25430293d1b7.tar.xz
hercules-a70955368115603b5c9856ecb24e25430293d1b7.zip
Merge pull request #2106 from MishimaHaruna/shutdownfix
Fix the shutdown callback (2015 regression)
Diffstat (limited to 'src')
-rw-r--r--src/common/console.c5
-rw-r--r--src/common/core.c11
2 files changed, 8 insertions, 8 deletions
diff --git a/src/common/console.c b/src/common/console.c
index 0b0a900f6..e7edd7e1e 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -133,7 +133,10 @@ int console_parse_key_pressed(void)
**/
CPCMD_C(exit, server)
{
- core->runflag = 0;
+ if (core->shutdown_callback != NULL)
+ core->shutdown_callback();
+ else
+ core->runflag = CORE_ST_STOP;
}
/**
diff --git a/src/common/core.c b/src/common/core.c
index 1bd332eec..406bb7629 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -80,9 +80,6 @@
// And don't complain to us if the XYZ plugin you installed wiped your hard disk, or worse.
// Note: This feature is deprecated, and should not be used.
-/// Called when a terminate signal is received.
-void (*shutdown_callback)(void) = NULL;
-
struct core_interface core_s;
struct core_interface *core = &core_s;
@@ -128,8 +125,8 @@ static BOOL WINAPI console_handler(DWORD c_event)
case CTRL_CLOSE_EVENT:
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
- if( shutdown_callback != NULL )
- shutdown_callback();
+ if (core->shutdown_callback != NULL)
+ core->shutdown_callback();
else
core->runflag = CORE_ST_STOP;// auto-shutdown
break;
@@ -158,8 +155,8 @@ static void sig_proc(int sn)
case SIGTERM:
if (++is_called > 3)
exit(EXIT_SUCCESS);
- if( shutdown_callback != NULL )
- shutdown_callback();
+ if (core->shutdown_callback != NULL)
+ core->shutdown_callback();
else
core->runflag = CORE_ST_STOP;// auto-shutdown
break;