]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Rehash from console works again due to new signalhandler. TODO: Use this to catch...
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 25 Jul 2007 19:46:25 +0000 (19:46 +0000)
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 25 Jul 2007 19:46:25 +0000 (19:46 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7571 e03df62e-2008-0410-955e-edbf42e46eb7

include/inspircd.h
src/inspircd.cpp
src/server.cpp

index 13b66ade7536fb0ca9354581a4eed8499fc08b61..fff30df9f3f0b5da0f87ad02b798f1093ff745e9 100644 (file)
@@ -62,8 +62,6 @@
  */
 #define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) )
 
-
-
 /** Delete a pointer, and NULL its value
  */
 template<typename T> inline void DELETE(T* x)
@@ -490,6 +488,10 @@ class CoreExport InspIRCd : public classbase
         */
        time_t next_call;
 
+       /** Set to the current signal recieved
+        */
+       int s_signal;
+
        /** Get the current time
         * Because this only calls time() once every time around the mainloop,
         * it is much faster than calling time() directly.
@@ -674,9 +676,18 @@ class CoreExport InspIRCd : public classbase
        bool IsChannel(const char *chname);
 
        /** Rehash the local server
-        * @param status This value is unused, and required for signal handler functions
         */
-       static void Rehash(int status);
+       void Rehash();
+
+       /** Handles incoming signals after being set
+        * @param signal the signal recieved
+        */
+       void SignalHandler(int signal);
+
+       /** Sets the signal recieved    
+        * @param signal the signal recieved
+        */
+       static void SetSignal(int signal);
 
        /** Causes the server to exit after unloading modules and
         * closing all open file descriptors.
index 449bb005b2a2a68659f6c46f28c750af408af278..240db1c88f8417bf3c1a4c4a05f53b2c356ac957 100644 (file)
@@ -152,6 +152,7 @@ using irc::sockets::insp_inaddr;
 using irc::sockets::insp_sockaddr;
 
 InspIRCd* SI = NULL;
+int* mysig = NULL;
 
 /* Burlex: Moved from exitcodes.h -- due to duplicate symbols */
 const char* ExitCodes[] =
@@ -305,7 +306,7 @@ void InspIRCd::SetSignals()
 {
 #ifndef WIN32
        signal(SIGALRM, SIG_IGN);
-       signal(SIGHUP, InspIRCd::Rehash);
+       signal(SIGHUP, InspIRCd::SetSignal);
        signal(SIGPIPE, SIG_IGN);
        signal(SIGCHLD, SIG_IGN);
 #endif
@@ -411,6 +412,8 @@ InspIRCd::InspIRCd(int argc, char** argv)
        memset(&server, 0, sizeof(server));
        memset(&client, 0, sizeof(client));
 
+       this->s_signal = 0;
+
        this->unregistered_count = 0;
 
        this->clientlist = new user_hash();
@@ -704,6 +707,13 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
 
        /* If any inspsockets closed, remove them */
        this->InspSocketCull();
+
+       if (this->s_signal)
+       {
+               this->SignalHandler(s_signal);
+               this->s_signal = 0;
+       }
+
 }
 
 void InspIRCd::InspSocketCull()
@@ -736,6 +746,7 @@ int InspIRCd::Run()
 int main(int argc, char** argv)
 {
        SI = new InspIRCd(argc, argv);
+       mysig = &SI->s_signal;
        SI->Run();
        delete SI;
        return 0;
@@ -804,3 +815,9 @@ int InspIRCd::GetTimeDelta()
 {
        return time_delta;
 }
+
+void InspIRCd::SetSignal(int signal)
+{
+       *mysig = signal;
+}
+    
index 2ab452fc8cb50f401d1370cb8e3d80492c342565..7f05aee7bdca6402b09e048afa8b31ce1b4360f3 100644 (file)
  * ---------------------------------------------------
  */
 
+#include <signal.h>
 #include "inspircd.h"
 
-void InspIRCd::Rehash(int status)
+
+void InspIRCd::SignalHandler(int signal)
+{
+       switch (signal)
+       {
+               case SIGHUP:
+                       Rehash();
+                       break;
+       }
+}
+
+void InspIRCd::Rehash()
 {
-/*
-       SI->WriteOpers("*** Rehashing config file %s due to SIGHUP",ServerConfig::CleanFilename(SI->ConfigFileName));
-       SI->CloseLog();
-       SI->OpenLog(SI->Config->argv, SI->Config->argc);
-       SI->RehashUsersAndChans();
-       FOREACH_MOD_I(SI, I_OnGarbageCollect, OnGarbageCollect());
-       SI->Config->Read(false,NULL);
-       SI->ResetMaxBans();
-       SI->Res->Rehash();
-       FOREACH_MOD_I(SI,I_OnRehash,OnRehash(NULL,""));
-       SI->BuildISupport();
-*/
+       this->WriteOpers("*** Rehashing config file %s due to SIGHUP",ServerConfig::CleanFilename(this->ConfigFileName));
+       this->CloseLog();
+       this->OpenLog(this->Config->argv, this->Config->argc);
+       this->RehashUsersAndChans();
+       FOREACH_MOD_I(this, I_OnGarbageCollect, OnGarbageCollect());
+       this->Config->Read(false,NULL);
+       this->ResetMaxBans();
+       this->Res->Rehash();
+       FOREACH_MOD_I(this,I_OnRehash,OnRehash(NULL,""));
+       this->BuildISupport();
 }
 
 void InspIRCd::RehashServer()