X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fsighandlers.c;h=e352d586e80c9c62743b8c01ec5d0ffe354be832;hb=7207bef418c655107d3076b20dd797418ad82cd7;hp=80eef3e603d3a382f2e31bf8511ce4433c24c218;hpb=ba720fcbaeaacee700d7d23936cf481e6fcb83b1;p=ngircd-alex.git diff --git a/src/ngircd/sighandlers.c b/src/ngircd/sighandlers.c index 80eef3e6..e352d586 100644 --- a/src/ngircd/sighandlers.c +++ b/src/ngircd/sighandlers.c @@ -1,5 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon + * Copyright (c)2001-2015 Alexander Barton (alex@barton.de) and Contributors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,15 +24,15 @@ #include #include #include +#include -#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 "sighandlers.h" static int signalpipe[2]; @@ -40,7 +41,6 @@ static const int signals_catch[] = { SIGINT, SIGQUIT, SIGTERM, SIGHUP, SIGCHLD, SIGUSR1, SIGUSR2 }; - #ifdef DEBUG static void @@ -48,7 +48,11 @@ Dump_State(void) { Log(LOG_DEBUG, "--- Internal server state: %s ---", Client_ID(Client_ThisServer())); - Log(LOG_DEBUG, "time()=%ld", time(NULL)); +#ifdef HAVE_LONG_LONG + Log(LOG_DEBUG, "time()=%llu", (unsigned long long)time(NULL)); +#else + Log(LOG_DEBUG, "time()=%lu", (unsigned long)time(NULL)); +#endif Conf_DebugDump(); Conn_DebugDump(); Client_DebugDump(); @@ -57,7 +61,6 @@ Dump_State(void) #endif - static void Signal_Block(int sig) { @@ -73,7 +76,6 @@ Signal_Block(int sig) #endif } - static void Signal_Unblock(int sig) { @@ -90,7 +92,6 @@ Signal_Unblock(int sig) #endif } - /** * Reload the server configuration file. */ @@ -102,7 +103,7 @@ Rehash(void) Log( LOG_NOTICE|LOG_snotice, "Re-reading configuration NOW!" ); - /* Remember old server name and nick name length */ + /* Remember old server name and nickname length */ strlcpy( old_name, Conf_ServerName, sizeof old_name ); old_nicklen = Conf_MaxNickLength; @@ -113,22 +114,25 @@ Rehash(void) /* Close down all listening sockets */ Conn_ExitListeners( ); - /* Recover old server name and nick name length: these values can't + /* Recover old server name and nickname 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."); + 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."); + 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"); + Log(LOG_WARNING, + "Re-Initializing of SSL failed, using old keys!"); /* Start listening on sockets */ Conn_InitListeners( ); @@ -139,7 +143,6 @@ Rehash(void) Log( LOG_NOTICE|LOG_snotice, "Re-reading of configuration done." ); } /* Rehash */ - /** * Signal handler of ngIRCd. * This function is called whenever ngIRCd catches a signal sent by the @@ -198,7 +201,6 @@ Signal_Handler(int Signal) Signal_Block(Signal); } /* Signal_Handler */ - /** * Signal processing handler of ngIRCd. * This function is called from the main conn event loop in (io_dispatch) @@ -218,8 +220,11 @@ Signal_Handler_BH(int Signal) break; #ifdef DEBUG case SIGUSR2: - if (NGIRCd_Debug) + if (NGIRCd_Debug) { + Log(LOG_INFO|LOG_snotice, + "Got SIGUSR2, dumping internal state ..."); Dump_State(); + } break; default: Log(LOG_DEBUG, "Got signal %d! Ignored.", Signal); @@ -228,7 +233,6 @@ Signal_Handler_BH(int Signal) Signal_Unblock(Signal); } - static void Signal_Callback(int fd, short UNUSED what) { @@ -236,7 +240,7 @@ Signal_Callback(int fd, short UNUSED what) (void) what; do { - ret = read(fd, &sig, sizeof(sig)); + ret = (int)read(fd, &sig, sizeof(sig)); if (ret == sizeof(int)) Signal_Handler_BH(sig); } while (ret == sizeof(int)); @@ -245,19 +249,19 @@ Signal_Callback(int fd, short UNUSED what) if (errno == EAGAIN || errno == EINTR) return; - Log(LOG_EMERG, "read from signal pipe: %s", strerror(errno)); + Log(LOG_EMERG, "Read from signal pipe: %s - Exiting!", + strerror(errno)); exit(1); } - Log(LOG_EMERG, "EOF on signal pipe"); + Log(LOG_EMERG, "EOF on signal pipe!? - Exiting!"); exit(1); } - /** * Initialize the signal handlers, catch * those signals we are interested in and sets SIGPIPE to be ignored. - * @return true if initialization was sucessful. + * @return true if initialization was successful. */ bool Signals_Init(void) @@ -303,9 +307,8 @@ Signals_Init(void) return io_event_create(signalpipe[0], IO_WANTREAD, Signal_Callback); } /* Signals_Init */ - /** - * Restores signals to their default behaviour. + * Restores signals to their default behavior. * * This should be called after a fork() in the new * child prodcess, especially when we are about to call @@ -326,11 +329,12 @@ Signals_Exit(void) sigaction(SIGPIPE, &saction, NULL); #else for (i=0; i < C_ARRAY_SIZE(signals_catch) ; i++) - sigaction(signals_catch[i], &saction, NULL); + signal(signals_catch[i], SIG_DFL); signal(SIGPIPE, SIG_DFL); #endif close(signalpipe[1]); close(signalpipe[0]); + signalpipe[0] = signalpipe[1] = 0; } /* -eof- */