]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_spanningtree Call the OnServerSplit hook from the OnUnloadModule() handler on unload
authorAttila Molnar <attilamolnar@hush.com>
Mon, 25 Apr 2016 11:15:06 +0000 (13:15 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Mon, 25 Apr 2016 11:15:06 +0000 (13:15 +0200)
src/modules/m_spanningtree/main.cpp

index 5b3f9c0bb6ea257bae77322e19be9619aec650d3..0b9bb65dff166cb8ecd113bfaad3f7807cc66bcd 100644 (file)
@@ -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();