summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd_die.cpp2
-rw-r--r--src/configreader.cpp2
-rw-r--r--src/inspircd.cpp17
-rw-r--r--src/server.cpp17
-rw-r--r--src/socketengine_epoll.cpp2
-rw-r--r--src/socketengine_iocp.cpp2
-rw-r--r--src/socketengine_kqueue.cpp2
-rw-r--r--src/socketengine_ports.cpp2
8 files changed, 25 insertions, 21 deletions
diff --git a/src/cmd_die.cpp b/src/cmd_die.cpp
index 7f0a81df8..734ee8ba3 100644
--- a/src/cmd_die.cpp
+++ b/src/cmd_die.cpp
@@ -35,7 +35,7 @@ CmdResult cmd_die::Handle (const char** parameters, int pcnt, userrec *user)
if (ServerInstance->Config->DieDelay)
sleep(ServerInstance->Config->DieDelay);
- InspIRCd::Exit(EXIT_STATUS_DIE);
+ ServerInstance->Exit(EXIT_STATUS_DIE);
}
else
{
diff --git a/src/configreader.cpp b/src/configreader.cpp
index d4291692f..fc6bdc200 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -550,7 +550,7 @@ void ServerConfig::ReportConfigError(const std::string &errormessage, bool bail,
{
/* Unneeded because of the ServerInstance->Log() aboive? */
printf("There were errors in your configuration:\n%s\n\n",errormessage.c_str());
- InspIRCd::Exit(EXIT_STATUS_CONFIG);
+ ServerInstance->Exit(EXIT_STATUS_CONFIG);
}
else
{
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 240db1c88..0f599eda6 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -175,19 +175,6 @@ const char* ExitCodes[] =
"Received SIGTERM", /* 15 */
};
-void InspIRCd::Exit(int status)
-{
-#ifdef WINDOWS
- CloseIPC();
-#endif
- if (SI)
- {
- SI->SendError("Exiting with status " + ConvToStr(status) + " (" + std::string(ExitCodes[status]) + ")");
- SI->Cleanup();
- }
- exit (status);
-}
-
void InspIRCd::Cleanup()
{
std::vector<std::string> mymodnames;
@@ -310,7 +297,7 @@ void InspIRCd::SetSignals()
signal(SIGPIPE, SIG_IGN);
signal(SIGCHLD, SIG_IGN);
#endif
- signal(SIGTERM, InspIRCd::Exit);
+ signal(SIGTERM, InspIRCd::SetSignal);
}
void InspIRCd::QuickExit(int status)
@@ -346,7 +333,7 @@ bool InspIRCd::DaemonSeed()
umask (007);
printf("InspIRCd Process ID: \033[1;32m%lu\033[0m\n",(unsigned long)getpid());
- signal(SIGTERM, InspIRCd::Exit);
+ signal(SIGTERM, InspIRCd::SetSignal);
rlimit rl;
if (getrlimit(RLIMIT_CORE, &rl) == -1)
diff --git a/src/server.cpp b/src/server.cpp
index 7f05aee7b..0f931da07 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -12,6 +12,7 @@
*/
#include <signal.h>
+#include "exitcodes.h"
#include "inspircd.h"
@@ -22,9 +23,25 @@ void InspIRCd::SignalHandler(int signal)
case SIGHUP:
Rehash();
break;
+ case SIGTERM:
+ Exit(signal);
+ break;
}
}
+void InspIRCd::Exit(int status)
+{
+#ifdef WINDOWS
+ CloseIPC();
+#endif
+ if (this)
+ {
+ this->SendError("Exiting with status " + ConvToStr(status) + " (" + std::string(ExitCodes[status]) + ")");
+ this->Cleanup();
+ }
+ exit (status);
+}
+
void InspIRCd::Rehash()
{
this->WriteOpers("*** Rehashing config file %s due to SIGHUP",ServerConfig::CleanFilename(this->ConfigFileName));
diff --git a/src/socketengine_epoll.cpp b/src/socketengine_epoll.cpp
index 4ed68ca57..03a3f8f7c 100644
--- a/src/socketengine_epoll.cpp
+++ b/src/socketengine_epoll.cpp
@@ -26,7 +26,7 @@ EPollEngine::EPollEngine(InspIRCd* Instance) : SocketEngine(Instance)
ServerInstance->Log(SPARSE,"ERROR: Your kernel probably does not have the proper features. This is a fatal error, exiting now.");
printf("ERROR: Could not initialize socket engine: %s\n", strerror(errno));
printf("ERROR: Your kernel probably does not have the proper features. This is a fatal error, exiting now.\n");
- InspIRCd::Exit(EXIT_STATUS_SOCKETENGINE);
+ ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
}
CurrentSetSize = 0;
}
diff --git a/src/socketengine_iocp.cpp b/src/socketengine_iocp.cpp
index ab894299c..c61b44062 100644
--- a/src/socketengine_iocp.cpp
+++ b/src/socketengine_iocp.cpp
@@ -26,7 +26,7 @@ IOCPEngine::IOCPEngine(InspIRCd * Instance) : SocketEngine(Instance)
ServerInstance->Log(SPARSE,"ERROR: this is a fatal error, exiting now.");
printf("ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
printf("ERROR: this is a fatal error, exiting now.");
- InspIRCd::Exit(EXIT_STATUS_SOCKETENGINE);
+ ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
}
/* Null variables out. */
diff --git a/src/socketengine_kqueue.cpp b/src/socketengine_kqueue.cpp
index 7fcdae2b6..246b5e524 100644
--- a/src/socketengine_kqueue.cpp
+++ b/src/socketengine_kqueue.cpp
@@ -28,7 +28,7 @@ KQueueEngine::KQueueEngine(InspIRCd* Instance) : SocketEngine(Instance)
ServerInstance->Log(SPARSE,"ERROR: this is a fatal error, exiting now.");
printf("ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
printf("ERROR: this is a fatal error, exiting now.");
- InspIRCd::Exit(EXIT_STATUS_SOCKETENGINE);
+ ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
}
CurrentSetSize = 0;
}
diff --git a/src/socketengine_ports.cpp b/src/socketengine_ports.cpp
index 869e0a6fb..a0141f79a 100644
--- a/src/socketengine_ports.cpp
+++ b/src/socketengine_ports.cpp
@@ -26,7 +26,7 @@ PortsEngine::PortsEngine(InspIRCd* Instance) : SocketEngine(Instance)
ServerInstance->Log(SPARSE,"ERROR: This is a fatal error, exiting now.");
printf("ERROR: Could not initialize socket engine: %s\n", strerror(errno));
printf("ERROR: This is a fatal error, exiting now.\n");
- InspIRCd::Exit(EXIT_STATUS_SOCKETENGINE);
+ ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
}
CurrentSetSize = 0;
}