diff options
author | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-07-25 19:46:25 +0000 |
---|---|---|
committer | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-07-25 19:46:25 +0000 |
commit | eadd5cce87ff5d17a3506bc0750e21e3d5035143 (patch) | |
tree | 88c7b53402a664e927a3a22ab88414bab3f79eb0 /src | |
parent | c39ccd1fdaef9ac6fd62888badc0240e8a88c55a (diff) |
Rehash from console works again due to new signalhandler. TODO: Use this to catch SIGTERM and exit cleanly.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7571 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 19 | ||||
-rw-r--r-- | src/server.cpp | 36 |
2 files changed, 41 insertions, 14 deletions
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() |