summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-23 14:19:33 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-23 14:19:33 +0000
commit529c6acc0177651e0b01cc6d7dcb7509fce17d14 (patch)
treeaf36cb6a39faf8442a7cb7bab162c13f0531c53e
parent371daf9928def23164b49b39ced1d3cdeb9225b8 (diff)
Unload as many modules as we can on restart, and close listeners
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6068 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/socket.h3
-rw-r--r--src/inspircd.cpp20
-rw-r--r--src/socket.cpp10
3 files changed, 33 insertions, 0 deletions
diff --git a/include/socket.h b/include/socket.h
index e9a832b9c..b8f6387d3 100644
--- a/include/socket.h
+++ b/include/socket.h
@@ -152,6 +152,9 @@ class ListenSocket : public EventHandler
/** Handle an I/O event
*/
void HandleEvent(EventType et, int errornum = 0);
+ /** Close the socket
+ */
+ ~ListenSocket();
};
#endif
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 670fb5ef7..786ff97b2 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -68,8 +68,28 @@ void InspIRCd::Exit(int status)
void InspIRCd::Restart(const std::string &reason)
{
+ std::vector<std::string> mymodnames;
+ int MyModCount = ModCount;
+
this->SendError(reason);
+
+ this->Log(DEBUG,"Closing listening client sockets...");
+ for (unsigned int i = 0; i < stats->BoundPortCount; i++)
+ /* This calls the constructor and closes the listening socket */
+ delete Config->openSockfd[i];
+
+ /* Unload all modules, so they get a chance to clean up their listeners */
+ for (int j = 0; j < ModCount; j++)
+ mymodnames.push_back(Config->module_names[j]);
+
+ this->Log(DEBUG,"Unloading modules...");
+ for (int k = 0; k < MyModCount; k++)
+ this->UnloadModule(mymodnames[k].c_str());
+
std::string me = Config->MyDir + "/inspircd";
+
+ this->Log(DEBUG,"Closing log and calling execv to start new instance of '%s'...", me.c_str());
+
this->Logger->Close();
if (execv(me.c_str(), Config->argv) == -1)
{
diff --git a/src/socket.cpp b/src/socket.cpp
index 70356be6c..ee21400d3 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -47,6 +47,16 @@ ListenSocket::ListenSocket(InspIRCd* Instance, int sockfd, insp_sockaddr client,
}
}
+ListenSocket::~ListenSocket()
+{
+ if (this->GetFd() > -1)
+ {
+ shutdown(this->fd, 2);
+ close(this->fd);
+ this->fd = -1;
+ }
+}
+
void ListenSocket::HandleEvent(EventType et, int errornum)
{
insp_sockaddr sock_us; // our port number