From 48178704ef7f9fa4b18be53854cf7dda9450f71f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 16 Feb 2005 19:03:38 +0000 Subject: [PATCH] * master_cleanup() now passes along an exit code from its caller to the OS. --- citadel/ChangeLog | 4 ++++ citadel/citserver.c | 8 +++----- citadel/citserver.h | 2 +- citadel/housekeeping.c | 2 +- citadel/server_main.c | 2 +- citadel/sysdep.c | 9 ++------- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index a9145bac3..a687a2d5a 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 640.10 2005/02/16 19:03:38 ajc + * master_cleanup() now passes along an exit code from its caller to the OS. + Revision 640.9 2005/02/16 18:48:39 ajc * Try to reach our cleanup routine when SIGSEGV is caught. Hopefully we'll get there and we can close the databases cleanly. @@ -6408,3 +6411,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citserver.c b/citadel/citserver.c index 0ff5725e9..88a7ad0ad 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -125,10 +125,8 @@ void master_startup(void) { /* * Cleanup routine to be called when the server is shutting down. - * WARNING: It's no longer safe to call this function to force a shutdown. - * Instead, set time_to_die = 1. */ -void master_cleanup(void) { +void master_cleanup(int exitcode) { struct CleanupFunctionHook *fcn; static int already_cleaning_up = 0; @@ -152,9 +150,9 @@ void master_cleanup(void) { #endif /* Now go away. */ - lprintf(CTDL_NOTICE, "citserver: exiting.\n"); + lprintf(CTDL_NOTICE, "citserver: Exiting with status %d.\n", exitcode); fflush(stdout); fflush(stderr); - exit(0); + exit(exitcode); } diff --git a/citadel/citserver.h b/citadel/citserver.h index 2288541be..b5d27a243 100644 --- a/citadel/citserver.h +++ b/citadel/citserver.h @@ -13,7 +13,7 @@ struct UserProcList { }; void master_startup (void); -void master_cleanup (void); +void master_cleanup (int exitcode); void RemoveContext (struct CitContext *); void set_wtmpsupp (char *newtext); void set_wtmpsupp_to_current_room(void); diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index 1b8deeb9a..9bb4624bb 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -82,7 +82,7 @@ void check_sched_shutdown(void) { if ((ScheduledShutdown == 1) && (ContextList == NULL)) { lprintf(CTDL_NOTICE, "Scheduled shutdown initiating.\n"); time_to_die = 1; - master_cleanup(); + master_cleanup(0); } } diff --git a/citadel/server_main.c b/citadel/server_main.c index 6e25f3cc6..c4d6c5e24 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -229,6 +229,6 @@ int main(int argc, char **argv) /* Server is exiting. Wait for workers to shutdown. */ lprintf(CTDL_INFO, "Server is shutting down.\n"); - master_cleanup(); + master_cleanup(0); return(0); } diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 4457591a4..5b51e1286 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -160,12 +160,7 @@ void lprintf(enum LogLevel loglevel, const char *format, ...) { /* - * We used to use master_cleanup() as a signal handler to shut down the server. - * however, master_cleanup() and the functions it calls do some things that - * aren't such a good idea to do from a signal handler: acquiring mutexes, - * playing with signal masks on BSDI systems, etc. so instead we install the - * following signal handler to set a global variable to inform the main loop - * that it's time to call master_cleanup() and exit. + * Signal handler to shut down the server. */ volatile int time_to_die = 0; @@ -173,7 +168,7 @@ volatile int time_to_die = 0; static RETSIGTYPE signal_cleanup(int signum) { lprintf(CTDL_DEBUG, "Caught signal %d; shutting down.\n", signum); time_to_die = 1; - master_cleanup(); /* will this work? */ + master_cleanup(signum); } -- 2.30.2