]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_httpd On module unload close all connections hooked by the module being unloaded
authorAttila Molnar <attilamolnar@hush.com>
Wed, 10 Dec 2014 16:50:31 +0000 (17:50 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 10 Dec 2014 16:50:31 +0000 (17:50 +0100)
src/modules/m_httpd.cpp

index 2a430d9674fb9669825604d91db5adf6355b6448..2b079c6ff9fe19d017d8347332f38d4b0a66fe95 100644 (file)
@@ -348,7 +348,7 @@ class ModuleHttpServer : public Module
        void init()
        {
                HttpModule = this;
-               Implementation eventlist[] = { I_OnAcceptConnection, I_OnBackgroundTimer, I_OnRehash };
+               Implementation eventlist[] = { I_OnAcceptConnection, I_OnBackgroundTimer, I_OnRehash, I_OnUnloadModule };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
                OnRehash(NULL);
        }
@@ -397,6 +397,20 @@ class ModuleHttpServer : public Module
                }
        }
 
+       void OnUnloadModule(Module* mod)
+       {
+               for (std::set<HttpServerSocket*>::const_iterator i = sockets.begin(); i != sockets.end(); )
+               {
+                       HttpServerSocket* sock = *i;
+                       ++i;
+                       if (sock->GetIOHook() == mod)
+                       {
+                               sock->cull();
+                               delete sock;
+                       }
+               }
+       }
+
        CullResult cull()
        {
                std::set<HttpServerSocket*> local;