]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd.cpp
Merge pull request #1168 from SaberUK/master+fix-configure-cache-parser
[user/henk/code/inspircd.git] / src / modules / m_httpd.cpp
index 3558b0a2b365680b06c8e12aa188f50d24922fc2..760647d47f1ae796636e8de03bedf1045cf3ae6c 100644 (file)
@@ -29,7 +29,6 @@
 class ModuleHttpServer;
 
 static ModuleHttpServer* HttpModule;
-static bool claimed;
 static insp::intrusive_list<HttpServerSocket> sockets;
 static Events::ModuleEventProvider* aclevprov;
 static Events::ModuleEventProvider* reqevprov;
@@ -324,13 +323,12 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
        {
                InternalState = HTTP_SERVE_SEND_DATA;
 
-               claimed = false;
                ModResult MOD_RESULT;
-               HTTPRequest acl((Module*)HttpModule, "httpd_acl", request_type, uri, &headers, this, ip, postdata);
+               HTTPRequest acl(request_type, uri, &headers, this, ip, postdata);
                FIRST_MOD_RESULT_CUSTOM(*aclevprov, HTTPACLEventListener, OnHTTPACLCheck, MOD_RESULT, (acl));
                if (MOD_RESULT != MOD_RES_DENY)
                {
-                       HTTPRequest url((Module*)HttpModule, "httpd_url", request_type, uri, &headers, this, ip, postdata);
+                       HTTPRequest url(request_type, uri, &headers, this, ip, postdata);
                        FIRST_MOD_RESULT_CUSTOM(*reqevprov, HTTPRequestEventListener, OnHTTPRequest, MOD_RESULT, (url));
                        if (MOD_RESULT == MOD_RES_PASSTHRU)
                        {
@@ -366,7 +364,6 @@ class HTTPdAPIImpl : public HTTPdAPIBase
 
        void SendResponse(HTTPDocumentResponse& resp) CXX11_OVERRIDE
        {
-               claimed = true;
                resp.src.sock->Page(resp.document, resp.responsecode, &resp.headers);
        }
 };
@@ -410,6 +407,20 @@ class ModuleHttpServer : public Module
                return MOD_RES_ALLOW;
        }
 
+       void OnUnloadModule(Module* mod)
+       {
+               for (insp::intrusive_list<HttpServerSocket>::const_iterator i = sockets.begin(); i != sockets.end(); )
+               {
+                       HttpServerSocket* sock = *i;
+                       ++i;
+                       if (sock->GetIOHook() && sock->GetIOHook()->prov->creator == mod)
+                       {
+                               sock->cull();
+                               delete sock;
+                       }
+               }
+       }
+
        CullResult cull() CXX11_OVERRIDE
        {
                for (insp::intrusive_list<HttpServerSocket>::const_iterator i = sockets.begin(); i != sockets.end(); ++i)