summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r--src/modules/m_spanningtree/main.cpp16
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp8
2 files changed, 21 insertions, 3 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 5b3f9c0bb..0b9bb65df 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -25,6 +25,7 @@
#include "socket.h"
#include "xline.h"
#include "iohook.h"
+#include "modules/spanningtree.h"
#include "resolvers.h"
#include "main.h"
@@ -613,6 +614,21 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod)
return;
ServerInstance->PI->SendMetaData("modules", "-" + mod->ModuleSourceFile);
+ if (mod == this)
+ {
+ // We are being unloaded, inform modules about all servers splitting which cannot be done later when the servers are actually disconnected
+ const server_hash& servers = Utils->serverlist;
+ for (server_hash::const_iterator i = servers.begin(); i != servers.end(); ++i)
+ {
+ TreeServer* server = i->second;
+ if (!server->IsRoot())
+ FOREACH_MOD_CUSTOM(GetEventProvider(), SpanningTreeEventListener, OnServerSplit, (server));
+ }
+ return;
+ }
+
+ // Some other module is being unloaded. If it provides an IOHook we use, we must close that server connection now.
+
restart:
// Close all connections which use an IO hook provided by this module
const TreeServer::ChildServers& list = Utils->TreeRoot->GetChildren();
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index 1fc9455b0..b29bea134 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -115,6 +115,8 @@ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const s
this->AddHashEntry();
Parent->Children.push_back(this);
+
+ FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), SpanningTreeEventListener, OnServerLink, (this));
}
void TreeServer::BeginBurst(uint64_t startms)
@@ -151,7 +153,6 @@ void TreeServer::FinishBurst()
unsigned long bursttime = ts - this->StartBurst;
ServerInstance->SNO->WriteToSnoMask(Parent == Utils->TreeRoot ? 'l' : 'L', "Received end of netburst from \2%s\2 (burst time: %lu %s)",
GetName().c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs"));
- FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), SpanningTreeEventListener, OnServerLink, (this));
StartBurst = 0;
FinishBurstInternal();
@@ -159,8 +160,6 @@ void TreeServer::FinishBurst()
void TreeServer::SQuitChild(TreeServer* server, const std::string& reason)
{
- if (!Utils->Creator->dying)
- FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), SpanningTreeEventListener, OnServerSplit, (server));
stdalgo::erase(Children, server);
if (IsRoot())
@@ -205,6 +204,9 @@ void TreeServer::SQuitInternal(unsigned int& num_lost_servers)
isdead = true;
num_lost_servers++;
RemoveHash();
+
+ if (!Utils->Creator->dying)
+ FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), SpanningTreeEventListener, OnServerSplit, (this));
}
unsigned int TreeServer::QuitUsers(const std::string& reason)