From e04f190f6377e76d2f3c5b0ece40507f19531ae7 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 23 Dec 2006 16:06:16 +0000 Subject: 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 --- src/inspircd.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src') 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 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::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) { -- cgit v1.2.3