summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h19
-rw-r--r--src/inspircd.cpp19
-rw-r--r--src/server.cpp36
3 files changed, 56 insertions, 18 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 13b66ade7..fff30df9f 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -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.
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 449bb005b..240db1c88 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -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;
+}
+
diff --git a/src/server.cpp b/src/server.cpp
index 2ab452fc8..7f05aee7b 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -11,22 +11,32 @@
* ---------------------------------------------------
*/
+#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()