From: brain Date: Mon, 23 Jul 2007 23:10:16 +0000 (+0000) Subject: Fix crash on unload of modules with listening sockets -- some situations require... X-Git-Tag: v2.0.23~4912 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=f12fd5382fef6aa5c6f75b2614460089a9af9f27;p=user%2Fhenk%2Fcode%2Finspircd.git Fix crash on unload of modules with listening sockets -- some situations require that the socket cull list is purged *immediately*, provide facility for this. Also squish some silly error output on unloading spanningtree. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7529 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/include/inspircd.h b/include/inspircd.h index c3f8ed328..79d3ae7ed 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -1273,6 +1273,11 @@ class CoreExport InspIRCd : public classbase * @return The return value for this function is undefined. */ int Run(); + + /** Force all InspSockets to be removed which are due to + * be culled. + */ + void InspSocketCull(); }; #endif diff --git a/src/inspircd.cpp b/src/inspircd.cpp index dbfbc1797..c35bf32c3 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1122,6 +1122,11 @@ void InspIRCd::DoOneIteration(bool process_module_sockets) GlobalCulls.Apply(); /* If any inspsockets closed, remove them */ + this->InspSocketCull(); +} + +void InspIRCd::InspSocketCull() +{ for (std::map::iterator x = SocketCull.begin(); x != SocketCull.end(); ++x) { SE->DelFd(x->second); diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 8494863a3..0e06f5363 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -405,9 +405,10 @@ class ModuleHttpServer : public Module for (size_t i = 0; i < httpsocks.size(); i++) { ServerInstance->SE->DelFd(httpsocks[i]); + httpsocks[i]->Close(); delete httpsocks[i]->GetIndex(); - delete httpsocks[i]; } + ServerInstance->InspSocketCull(); } virtual Version GetVersion() diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 4d960cf8a..c987cb590 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -212,6 +212,9 @@ void TreeSocket::OnError(InspSocketError e) { Link* MyLink; + if (this->LinkState == LISTENER) + return; + switch (e) { case I_ERR_CONNECT: diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index dcfb2b4aa..23362ca99 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -1501,6 +1501,9 @@ void TreeSocket::OnTimeout() void TreeSocket::OnClose() { + if (this->LinkState == LISTENER) + return; + // Connection closed. // If the connection is fully up (state CONNECTED) // then propogate a netsplit to all peers. diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 9d4fbf41a..bfd46ef03 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -202,6 +202,7 @@ SpanningTreeUtilities::~SpanningTreeUtilities() } } delete TreeRoot; + ServerInstance->InspSocketCull(); } void SpanningTreeUtilities::AddThisServer(TreeServer* server, TreeServerList &list)