From e054cbbdb28a9b555faafd689282140c01d55b3e Mon Sep 17 00:00:00 2001 From: flaviojs Date: Thu, 16 Jun 2011 10:22:35 +0000 Subject: * Merges from charmerge: - Added DBMap::exists. (r14090) - Added sv_parse_next, a stepped version of sv_parse (delim-separated parser). (r14100 r14104) - Added missing fd check to do_close. (r14145) - Normalized, refactored and restructured some code (in preparation for shutdown/reconnect code). (r14145 r14150) - Changed the char select request code to allow the char-server to reject it. (player in map-server trying to go to char select) (r14150) - Added shutdown support to the servers. (incomplete) (r14152) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14851 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/core.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/common/core.c') diff --git a/src/common/core.c b/src/common/core.c index b89cc3841..bfa563d8c 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -24,7 +24,12 @@ #include #endif -int runflag = 1; + +/// Called when a terminate signal is received. +void (*shutdown_callback)(void) = NULL; + + +int runflag = CORE_ST_RUN; int arg_c = 0; char **arg_v = NULL; @@ -78,7 +83,10 @@ static void sig_proc(int sn) case SIGTERM: if (++is_called > 3) exit(EXIT_SUCCESS); - runflag = 0; + if( shutdown_callback != NULL ) + shutdown_callback(); + else + runflag = CORE_ST_STOP;// auto-shutdown break; case SIGSEGV: case SIGFPE: @@ -249,7 +257,7 @@ int main (int argc, char **argv) {// Main runtime cycle int next; - while (runflag) { + while (runflag != CORE_ST_STOP) { next = do_timer(gettick_nocache()); do_sockets(next); } -- cgit v1.2.3-70-g09d2