summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-23 16:06:16 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-23 16:06:16 +0000
commite04f190f6377e76d2f3c5b0ece40507f19531ae7 (patch)
tree29b7bafe05f2d1d56aa02dc2d9b5bfb900c79da5 /src/inspircd.cpp
parentc1316150a7b0679494828b8acab8c8fa2c35fa7b (diff)
Program termination (including SIGTERM) now calls InspIRCd::Cleanup() which does most of the duties performed by InspIRCd::Restart().
This means that on controlled shutdown we give the modules a chance to unload, etc, and close our sockets and free ram in a proper way. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6075 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 876bf7f29..29b2105ce 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -63,25 +63,26 @@ bool InspIRCd::FindServerName(const std::string &servername)
void InspIRCd::Exit(int status)
{
+ if (SI)
+ {
+ SI->SendError("Exiting with status " + ConvToStr(status));
+ SI->Cleanup();
+ }
+
exit (status);
}
-void InspIRCd::Restart(const std::string &reason)
+void InspIRCd::Cleanup()
{
std::vector<std::string> mymodnames;
int MyModCount = this->GetModuleCount();
- /* SendError flushes each client's queue,
- * regardless of writeability state
- */
- this->SendError(reason);
-
for (unsigned int i = 0; i < stats->BoundPortCount; i++)
/* This calls the constructor and closes the listening socket */
delete Config->openSockfd[i];
/* We do this more than once, so that any service providers get a
- * chance to be* unhooked by the modules using them, but then get
+ * chance to be unhooked by the modules using them, but then get
* a chance to be removed themsleves.
*/
for (int tries = 0; tries < 3; tries++)
@@ -101,11 +102,21 @@ void InspIRCd::Restart(const std::string &reason)
for (std::vector<userrec*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++)
(*i)->CloseSocket();
- /* Figure out our filename (if theyve renamed it, we're boned) */
- std::string me = Config->MyDir + "/inspircd";
-
/* Close logging */
this->Logger->Close();
+}
+
+void InspIRCd::Restart(const std::string &reason)
+{
+ /* SendError flushes each client's queue,
+ * regardless of writeability state
+ */
+ this->SendError(reason);
+
+ this->Cleanup();
+
+ /* Figure out our filename (if theyve renamed it, we're boned) */
+ std::string me = Config->MyDir + "/inspircd";
if (execv(me.c_str(), Config->argv) == -1)
{