From 43a4bc5b8bb064e2dfca456ab6fcc656b4dfa813 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Thu, 19 Dec 2002 04:29:59 +0000 Subject: [PATCH] - New signal handler. --- src/ngircd/irc-oper.c | 14 +++++++------- src/ngircd/log.c | 4 ++-- src/ngircd/ngircd.c | 34 +++++++++++++++++----------------- src/ngircd/ngircd.h | 7 ++++--- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/ngircd/irc-oper.c b/src/ngircd/irc-oper.c index 7e50b653..2a63ea59 100644 --- a/src/ngircd/irc-oper.c +++ b/src/ngircd/irc-oper.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-oper.c,v 1.13 2002/12/12 12:33:14 alex Exp $"; +static char UNUSED id[] = "$Id: irc-oper.c,v 1.14 2002/12/19 04:30:00 alex Exp $"; #include "imp.h" #include @@ -90,8 +90,8 @@ IRC_DIE( CLIENT *Client, REQUEST *Req ) if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client )); - Log( LOG_NOTICE|LOG_snotice, "Got DIE command from \"%s\", going down!", Client_Mask( Client )); - NGIRCd_Quit = TRUE; + Log( LOG_NOTICE|LOG_snotice, "Got DIE command from \"%s\", shutdown triggered!", Client_Mask( Client )); + NGIRCd_SignalQuit = TRUE; return CONNECTED; } /* IRC_DIE */ @@ -107,8 +107,8 @@ IRC_REHASH( CLIENT *Client, REQUEST *Req ) if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client )); - Log( LOG_NOTICE|LOG_snotice, "Got REHASH command from \"%s\", re-reading configuration ...", Client_Mask( Client )); - NGIRCd_Rehash( ); + Log( LOG_NOTICE|LOG_snotice, "Got REHASH command from \"%s\", reload of configuration triggered.", Client_Mask( Client )); + NGIRCd_SignalRehash = TRUE; return CONNECTED; } /* IRC_REHASH */ @@ -125,8 +125,8 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req ) if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client )); - Log( LOG_NOTICE|LOG_snotice, "Got RESTART command from \"%s\", going down!", Client_Mask( Client )); - NGIRCd_Restart = TRUE; + Log( LOG_NOTICE|LOG_snotice, "Got RESTART command from \"%s\", shutdown triggered!", Client_Mask( Client )); + NGIRCd_SignalRestart = TRUE; return CONNECTED; } /* IRC_RESTART */ diff --git a/src/ngircd/log.c b/src/ngircd/log.c index 79f3c6fe..db0f0767 100644 --- a/src/ngircd/log.c +++ b/src/ngircd/log.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: log.c,v 1.41 2002/12/12 12:24:18 alex Exp $"; +static char UNUSED id[] = "$Id: log.c,v 1.42 2002/12/19 04:30:00 alex Exp $"; #include "imp.h" #include @@ -119,7 +119,7 @@ GLOBAL VOID Log_Exit( VOID ) { /* Good Bye! */ - if( NGIRCd_Restart ) Log( LOG_NOTICE, "%s done (restarting).", PACKAGE ); + if( NGIRCd_SignalRestart ) Log( LOG_NOTICE, "%s done (restarting).", PACKAGE ); else Log( LOG_NOTICE, "%s done.", PACKAGE ); /* Error-File (stderr) loeschen */ diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c index 1396d9ed..20db13ed 100644 --- a/src/ngircd/ngircd.c +++ b/src/ngircd/ngircd.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: ngircd.c,v 1.64 2002/12/12 11:31:21 alex Exp $"; +static char UNUSED id[] = "$Id: ngircd.c,v 1.65 2002/12/19 04:29:59 alex Exp $"; #include "imp.h" #include @@ -65,10 +65,8 @@ main( int argc, const char *argv[] ) umask( 0077 ); - NGIRCd_Restart = FALSE; - NGIRCd_Quit = FALSE; - NGIRCd_NoDaemon = FALSE; - NGIRCd_Passive = FALSE; + NGIRCd_SignalQuit = NGIRCd_SignalRestart = NGIRCd_SignalRehash = FALSE; + NGIRCd_NoDaemon = NGIRCd_Passive = FALSE; #ifdef DEBUG NGIRCd_Debug = FALSE; #endif @@ -220,7 +218,7 @@ main( int argc, const char *argv[] ) exit( Conf_Test( )); } - while( ! NGIRCd_Quit ) + while( ! NGIRCd_SignalQuit ) { /* In der Regel wird ein Sub-Prozess ge-fork()'t, der * nicht mehr mit dem Terminal verbunden ist. Mit der @@ -250,8 +248,9 @@ main( int argc, const char *argv[] ) /* Globale Variablen initialisieren */ NGIRCd_Start = time( NULL ); (VOID)strftime( NGIRCd_StartStr, 64, "%a %b %d %Y at %H:%M:%S (%Z)", localtime( &NGIRCd_Start )); - NGIRCd_Restart = FALSE; - NGIRCd_Quit = FALSE; + NGIRCd_SignalRehash = FALSE; + NGIRCd_SignalRestart = FALSE; + NGIRCd_SignalQuit = FALSE; /* Module initialisieren */ Log_Init( ); @@ -393,7 +392,10 @@ GLOBAL VOID NGIRCd_Rehash( VOID ) { CHAR old_name[CLIENT_ID_LEN]; - + + Log( LOG_NOTICE|LOG_snotice, "Re-reading configuration NOW!" ); + NGIRCd_SignalRehash = FALSE; + /* Alle Listen-Sockets schliessen */ Conn_ExitListeners( ); @@ -417,7 +419,7 @@ NGIRCd_Rehash( VOID ) /* Listen-Sockets neu anlegen: */ Conn_InitListeners( ); - Log( LOG_INFO, "Re-reading of configuration done." ); + Log( LOG_NOTICE|LOG_snotice, "Re-reading of configuration done." ); } /* NGIRCd_Rehash */ @@ -481,23 +483,21 @@ Signal_Handler( INT Signal ) case SIGINT: case SIGQUIT: /* wir soll(t)en uns wohl beenden ... */ - if( Signal == SIGTERM ) Log( LOG_WARNING|LOG_snotice, "Got TERM signal, terminating now ..." ); - else if( Signal == SIGINT ) Log( LOG_WARNING|LOG_snotice, "Got INT signal, terminating now ..." ); - else if( Signal == SIGQUIT ) Log( LOG_WARNING|LOG_snotice, "Got QUIT signal, terminating now ..." ); - NGIRCd_Quit = TRUE; + NGIRCd_SignalQuit = TRUE; break; case SIGHUP: /* Konfiguration neu einlesen: */ - Log( LOG_WARNING|LOG_snotice, "Got HUP signal, re-reading configuration ..." ); - NGIRCd_Rehash( ); + NGIRCd_SignalRehash = TRUE; break; case SIGCHLD: /* Child-Prozess wurde beendet. Zombies vermeiden: */ while( waitpid( -1, NULL, WNOHANG ) > 0); break; +#ifdef DEBUG default: /* unbekanntes bzw. unbehandeltes Signal */ - Log( LOG_NOTICE, "Got signal %d! Ignored.", Signal ); + Log( LOG_DEBUG, "Got signal %d! Ignored.", Signal ); +#endif } } /* Signal_Handler */ diff --git a/src/ngircd/ngircd.h b/src/ngircd/ngircd.h index 92d074b3..a9fd1514 100644 --- a/src/ngircd/ngircd.h +++ b/src/ngircd/ngircd.h @@ -8,7 +8,7 @@ * (at your option) any later version. * Please read the file COPYING, README and AUTHORS for more information. * - * $Id: ngircd.h,v 1.17 2002/12/12 11:30:23 alex Exp $ + * $Id: ngircd.h,v 1.18 2002/12/19 04:30:00 alex Exp $ * * Prototypes of the "main module". */ @@ -37,8 +37,9 @@ GLOBAL BOOLEAN NGIRCd_NoDaemon; /* nicht im Hintergrund laufen */ GLOBAL BOOLEAN NGIRCd_Passive; /* nicht zu anderen Servern connecten */ -GLOBAL BOOLEAN NGIRCd_Quit; /* TRUE: ngIRCd beenden */ -GLOBAL BOOLEAN NGIRCd_Restart; /* TRUE: neu starten */ +GLOBAL BOOLEAN NGIRCd_SignalQuit; /* TRUE: quit server*/ +GLOBAL BOOLEAN NGIRCd_SignalRestart; /* TRUE: restart server */ +GLOBAL BOOLEAN NGIRCd_SignalRehash; /* TRUE: reload configuration */ GLOBAL CHAR NGIRCd_DebugLevel[2]; /* Debug-Level fuer IRC_VERSION() */ -- 2.39.2