]> arthur.barton.de Git - ngircd-alex.git/commitdiff
- New signal handler.
authorAlexander Barton <alex@barton.de>
Thu, 19 Dec 2002 04:29:59 +0000 (04:29 +0000)
committerAlexander Barton <alex@barton.de>
Thu, 19 Dec 2002 04:29:59 +0000 (04:29 +0000)
src/ngircd/irc-oper.c
src/ngircd/log.c
src/ngircd/ngircd.c
src/ngircd/ngircd.h

index 7e50b653cc5df09f7b06d449cc97a32de95b66c5..2a63ea59e9eb78067b580f5490968d78fd8934be 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
 
 #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 <assert.h>
 
 #include "imp.h"
 #include <assert.h>
@@ -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 ));
 
 
        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 */
 
        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 ));
 
 
        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 */
        
        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 ));
 
 
        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 */
 
        return CONNECTED;
 } /* IRC_RESTART */
 
index 79f3c6fef7b9234506210fdb499b27e2b2dfd6a7..db0f076795c4c2f485533b6b7cf5633363c4b2ae 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
 
 #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 <assert.h>
 
 #include "imp.h"
 #include <assert.h>
@@ -119,7 +119,7 @@ GLOBAL VOID
 Log_Exit( VOID )
 {
        /* Good Bye! */
 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 */
        else Log( LOG_NOTICE, "%s done.", PACKAGE );
 
        /* Error-File (stderr) loeschen */
index 1396d9ed706f08da5e5cba9eaf1087f07e1272be..20db13ed94c96a5bb2a4e02df2e398c5e37f3751 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
 
 #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 <assert.h>
 
 #include "imp.h"
 #include <assert.h>
@@ -65,10 +65,8 @@ main( int argc, const char *argv[] )
 
        umask( 0077 );
 
 
        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
 #ifdef DEBUG
        NGIRCd_Debug = FALSE;
 #endif
@@ -220,7 +218,7 @@ main( int argc, const char *argv[] )
                exit( Conf_Test( ));
        }
        
                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
        {
                /* 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 ));
                /* 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( );
 
                /* Module initialisieren */
                Log_Init( );
@@ -393,7 +392,10 @@ GLOBAL VOID
 NGIRCd_Rehash( VOID )
 {
        CHAR old_name[CLIENT_ID_LEN];
 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( );
 
        /* Alle Listen-Sockets schliessen */
        Conn_ExitListeners( );
 
@@ -417,7 +419,7 @@ NGIRCd_Rehash( VOID )
        /* Listen-Sockets neu anlegen: */
        Conn_InitListeners( );
 
        /* 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 */
 
 
 } /* NGIRCd_Rehash */
 
 
@@ -481,23 +483,21 @@ Signal_Handler( INT Signal )
                case SIGINT:
                case SIGQUIT:
                        /* wir soll(t)en uns wohl beenden ... */
                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: */
                        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;
                        break;
                case SIGCHLD:
                        /* Child-Prozess wurde beendet. Zombies vermeiden: */
                        while( waitpid( -1, NULL, WNOHANG ) > 0);
                        break;
+#ifdef DEBUG
                default:
                        /* unbekanntes bzw. unbehandeltes Signal */
                default:
                        /* unbekanntes bzw. unbehandeltes Signal */
-                       Log( LOG_NOTICE, "Got signal %d! Ignored.", Signal );
+                       Log( LOG_DEBUG, "Got signal %d! Ignored.", Signal );
+#endif
        }
 } /* Signal_Handler */
 
        }
 } /* Signal_Handler */
 
index 92d074b3c3e7de18ff542eef5ff5b7e2cc55bc5a..a9fd1514fecd511813fd0b7aa54b478c76c44d79 100644 (file)
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
  * (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".
  */
  *
  * 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_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() */
 
 
 GLOBAL CHAR NGIRCd_DebugLevel[2];      /* Debug-Level fuer IRC_VERSION() */