]> code.citadel.org Git - citadel.git/blobdiff - citadel/sysdep.c
* master_cleanup() now passes along an exit code from its caller to the OS.
[citadel.git] / citadel / sysdep.c
index 353ab0ed8ad7ffe2020468ced248a3592f67c1b1..5b51e1286cb02f8600d3e1c57ed8304a57fd34d6 100644 (file)
@@ -160,18 +160,15 @@ 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;
 
 static RETSIGTYPE signal_cleanup(int signum) {
+       lprintf(CTDL_DEBUG, "Caught signal %d; shutting down.\n", signum);
        time_to_die = 1;
+       master_cleanup(signum);
 }
 
 
@@ -220,6 +217,7 @@ void init_sysdep(void) {
        signal(SIGQUIT, signal_cleanup);
        signal(SIGHUP, signal_cleanup);
        signal(SIGTERM, signal_cleanup);
+       signal(SIGSEGV, signal_cleanup);
 
        /*
         * Do not shut down the server on broken pipe signals, otherwise the
@@ -525,7 +523,9 @@ void client_write(char *buf, int nbytes)
        int bytes_written = 0;
        int retval;
        int sock;
+#ifndef HAVE_TCP_BUFFERING
        int old_buffer_len = 0;
+#endif
 
        if (CC->redirect_fp != NULL) {
                fwrite(buf, (size_t)nbytes, (size_t)1, CC->redirect_fp);