]> arthur.barton.de Git - ngircd-alex.git/commitdiff
remove NGIRCd_SignalRehash
authorFlorian Westphal <fw@strlen.de>
Fri, 10 Sep 2010 22:27:21 +0000 (00:27 +0200)
committerFlorian Westphal <fw@strlen.de>
Sat, 11 Sep 2010 09:36:12 +0000 (11:36 +0200)
now that the main signal handling is done from the dispatcher
loop we can call NGIRCD_Rehash() directly.

the /REHASH handler can queue the Rehash() function for
execution by sending a SIGHUP.  It will be run when we
return back to the dispatch loop.

src/ngircd/conn.c
src/ngircd/irc-oper.c
src/ngircd/ngircd.c
src/ngircd/ngircd.h
src/ngircd/sighandlers.c

index 03e2905cc5af0e1afa70f4299627d0cfbe43a373..e4851a933b42950b5b0cfcd7022a8403cc345057 100644 (file)
@@ -710,10 +710,6 @@ Conn_Handler(void)
                Rendezvous_Handler();
 #endif
 
                Rendezvous_Handler();
 #endif
 
-               /* Should the configuration be reloaded? */
-               if (NGIRCd_SignalRehash)
-                       NGIRCd_Rehash();
-
                /* Check configured servers and established links */
                Check_Servers();
                Check_Connections();
                /* Check configured servers and established links */
                Check_Servers();
                Check_Connections();
index a927b1951035aa5b34c0524c263cb6df2cda8c2c..048c4f8b099f335caf6d339655e85bc4bc24dd10 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <signal.h>
 
 #include "ngircd.h"
 #include "conn-func.h"
 
 #include "ngircd.h"
 #include "conn-func.h"
@@ -146,8 +147,8 @@ IRC_REHASH( CLIENT *Client, REQUEST *Req )
        if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
 
        Log( LOG_NOTICE|LOG_snotice, "Got REHASH command from \"%s\" ...", Client_Mask( Client ));
        if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
 
        Log( LOG_NOTICE|LOG_snotice, "Got REHASH command from \"%s\" ...", Client_Mask( Client ));
-       NGIRCd_SignalRehash = true;
-       
+       raise(SIGHUP);
+
        return CONNECTED;
 } /* IRC_REHASH */
 
        return CONNECTED;
 } /* IRC_REHASH */
 
index de0b490dab81a5aa025a859ac3801c17ffb602c8..2fd60ef8713295d08bd9276110539b65e97697c6 100644 (file)
@@ -93,7 +93,7 @@ main( int argc, const char *argv[] )
 
        umask( 0077 );
 
 
        umask( 0077 );
 
-       NGIRCd_SignalQuit = NGIRCd_SignalRestart = NGIRCd_SignalRehash = false;
+       NGIRCd_SignalQuit = NGIRCd_SignalRestart = false;
        NGIRCd_Passive = false;
 #ifdef DEBUG
        NGIRCd_Debug = false;
        NGIRCd_Passive = false;
 #ifdef DEBUG
        NGIRCd_Debug = false;
@@ -261,7 +261,6 @@ main( int argc, const char *argv[] )
                NGIRCd_Start = time( NULL );
                (void)strftime( NGIRCd_StartStr, 64, "%a %b %d %Y at %H:%M:%S (%Z)", localtime( &NGIRCd_Start ));
 
                NGIRCd_Start = time( NULL );
                (void)strftime( NGIRCd_StartStr, 64, "%a %b %d %Y at %H:%M:%S (%Z)", localtime( &NGIRCd_Start ));
 
-               NGIRCd_SignalRehash = false;
                NGIRCd_SignalRestart = false;
                NGIRCd_SignalQuit = false;
 
                NGIRCd_SignalRestart = false;
                NGIRCd_SignalQuit = false;
 
@@ -430,56 +429,6 @@ Fill_Version( void )
        } /* Fill_Version */
 
 
        } /* Fill_Version */
 
 
-/**
- * Reload the server configuration file.
- */
-GLOBAL void
-NGIRCd_Rehash( void )
-{
-       char old_name[CLIENT_ID_LEN];
-       unsigned old_nicklen;
-
-       Log( LOG_NOTICE|LOG_snotice, "Re-reading configuration NOW!" );
-       NGIRCd_SignalRehash = false;
-
-       /* Remember old server name and nick name length */
-       strlcpy( old_name, Conf_ServerName, sizeof old_name );
-       old_nicklen = Conf_MaxNickLength;
-
-       /* Re-read configuration ... */
-       if (!Conf_Rehash( ))
-               return;
-
-       /* Close down all listening sockets */
-       Conn_ExitListeners( );
-
-       /* Recover old server name and nick name length: these values can't
-        * be changed during run-time */
-       if (strcmp(old_name, Conf_ServerName) != 0 ) {
-               strlcpy(Conf_ServerName, old_name, sizeof Conf_ServerName);
-               Log(LOG_ERR, "Can't change \"ServerName\" on runtime! Ignored new name.");
-       }
-       if (old_nicklen != Conf_MaxNickLength) {
-               Conf_MaxNickLength = old_nicklen;
-               Log(LOG_ERR, "Can't change \"MaxNickLength\" on runtime! Ignored new value.");
-       }
-
-       /* Create new pre-defined channels */
-       Channel_InitPredefined( );
-
-       if (!ConnSSL_InitLibrary())
-               Log(LOG_WARNING, "Re-Initializing SSL failed, using old keys");
-
-       /* Start listening on sockets */
-       Conn_InitListeners( );
-
-       /* Sync configuration with established connections */
-       Conn_SyncServerStruct( );
-
-       Log( LOG_NOTICE|LOG_snotice, "Re-reading of configuration done." );
-} /* NGIRCd_Rehash */
-
-
 /**
  * Display copyright and version information of ngIRCd on the console.
  */
 /**
  * Display copyright and version information of ngIRCd on the console.
  */
index bd0aed0a7b5509337a1c3c460d00c43ed4d7f9ca..bd699e505094ddddbbfab2bdc46b23294ae664bf 100644 (file)
@@ -41,7 +41,6 @@ GLOBAL bool NGIRCd_Passive;           /* nicht zu anderen Servern connecten */
 
 GLOBAL bool NGIRCd_SignalQuit; /* true: quit server*/
 GLOBAL bool NGIRCd_SignalRestart;      /* true: restart server */
 
 GLOBAL bool NGIRCd_SignalQuit; /* true: quit server*/
 GLOBAL bool NGIRCd_SignalRestart;      /* true: restart server */
-GLOBAL bool 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() */
 
@@ -50,9 +49,6 @@ GLOBAL char NGIRCd_ConfFile[FNAME_LEN];       /* Konfigurationsdatei */
 GLOBAL char NGIRCd_ProtoID[COMMAND_LEN];/* Protokoll- und Server-Identifikation */
 
 
 GLOBAL char NGIRCd_ProtoID[COMMAND_LEN];/* Protokoll- und Server-Identifikation */
 
 
-GLOBAL void NGIRCd_Rehash PARAMS(( void ));
-
-
 #endif
 
 
 #endif
 
 
index f3ce24feb4935b77d13577ab66e526a7bedb9c81..d03692a2e2cc17539b2ec35c44d7a881977f2af2 100644 (file)
 #include <sys/wait.h>
 
 #include "imp.h"
 #include <sys/wait.h>
 
 #include "imp.h"
+#include "conn.h"
+#include "conf-ssl.h"
+#include "channel.h"
+#include "conf.h"
 #include "io.h"
 #include "log.h"
 #include "ngircd.h"
 #include "io.h"
 #include "log.h"
 #include "ngircd.h"
@@ -57,6 +61,55 @@ static void Signal_Unblock(int sig)
 #endif
 }
 
 #endif
 }
 
+/**
+ * Reload the server configuration file.
+ */
+static void
+NGIRCd_Rehash( void )
+{
+       char old_name[CLIENT_ID_LEN];
+       unsigned old_nicklen;
+
+       Log( LOG_NOTICE|LOG_snotice, "Re-reading configuration NOW!" );
+
+       /* Remember old server name and nick name length */
+       strlcpy( old_name, Conf_ServerName, sizeof old_name );
+       old_nicklen = Conf_MaxNickLength;
+
+       /* Re-read configuration ... */
+       if (!Conf_Rehash( ))
+               return;
+
+       /* Close down all listening sockets */
+       Conn_ExitListeners( );
+
+       /* Recover old server name and nick name length: these values can't
+        * be changed during run-time */
+       if (strcmp(old_name, Conf_ServerName) != 0 ) {
+               strlcpy(Conf_ServerName, old_name, sizeof Conf_ServerName);
+               Log(LOG_ERR, "Can't change \"ServerName\" on runtime! Ignored new name.");
+       }
+       if (old_nicklen != Conf_MaxNickLength) {
+               Conf_MaxNickLength = old_nicklen;
+               Log(LOG_ERR, "Can't change \"MaxNickLength\" on runtime! Ignored new value.");
+       }
+
+       /* Create new pre-defined channels */
+       Channel_InitPredefined( );
+
+       if (!ConnSSL_InitLibrary())
+               Log(LOG_WARNING, "Re-Initializing SSL failed, using old keys");
+
+       /* Start listening on sockets */
+       Conn_InitListeners( );
+
+       /* Sync configuration with established connections */
+       Conn_SyncServerStruct( );
+
+       Log( LOG_NOTICE|LOG_snotice, "Re-reading of configuration done." );
+} /* NGIRCd_Rehash */
+
+
 
 /**
  * Signal handler of ngIRCd.
 
 /**
  * Signal handler of ngIRCd.
@@ -76,9 +129,7 @@ static void Signal_Handler(int Signal)
                NGIRCd_SignalQuit = true;
                return;
        case SIGHUP:
                NGIRCd_SignalQuit = true;
                return;
        case SIGHUP:
-               /* re-read configuration */
-               NGIRCd_SignalRehash = true;
-               return;
+               break;
        case SIGCHLD:
                /* child-process exited, avoid zombies */
                while (waitpid( -1, NULL, WNOHANG) > 0)
        case SIGCHLD:
                /* child-process exited, avoid zombies */
                while (waitpid( -1, NULL, WNOHANG) > 0)
@@ -108,6 +159,10 @@ static void Signal_Handler(int Signal)
 static void Signal_Handler_BH(int Signal)
 {
        switch (Signal) {
 static void Signal_Handler_BH(int Signal)
 {
        switch (Signal) {
+       case SIGHUP:
+               /* re-read configuration */
+               NGIRCd_Rehash();
+               break;
 #ifdef DEBUG
        default:
                Log(LOG_DEBUG, "Got signal %d! Ignored.", Signal);
 #ifdef DEBUG
        default:
                Log(LOG_DEBUG, "Got signal %d! Ignored.", Signal);