diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-09-09 13:30:31 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-09-09 13:30:31 +0200 |
commit | c0f946f2b7195e101cdaae9d5453e0027d4204b4 (patch) | |
tree | 6f2925a315100fa84254ef98ce921ebb0cd6f51a /src | |
parent | 6f971a57e52e8f389e47ca5d626da1290a3d3b27 (diff) |
m_httpd Close all open http sockets on unload
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_httpd.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 37f715a8d..6315809a9 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -32,6 +32,7 @@ class ModuleHttpServer; static ModuleHttpServer* HttpModule; static bool claimed; +static std::set<HttpServerSocket*> sockets; /** HTTP socket states */ @@ -69,6 +70,11 @@ class HttpServerSocket : public BufferedSocket GetIOHook()->OnStreamSocketAccept(this, client, server); } + ~HttpServerSocket() + { + sockets.erase(this); + } + virtual void OnError(BufferedSocketError) { ServerInstance->GlobalCulls.AddItem(this); @@ -333,7 +339,6 @@ class HttpServerSocket : public BufferedSocket class ModuleHttpServer : public Module { - std::vector<HttpServerSocket *> httpsocks; public: void init() @@ -358,18 +363,21 @@ class ModuleHttpServer : public Module int port; std::string incomingip; irc::sockets::satoap(*client, incomingip, port); - new HttpServerSocket(nfd, incomingip, from, client, server); + sockets.insert(new HttpServerSocket(nfd, incomingip, from, client, server)); return MOD_RES_ALLOW; } - - virtual ~ModuleHttpServer() + CullResult cull() { - for (size_t i = 0; i < httpsocks.size(); i++) + std::set<HttpServerSocket*> local; + local.swap(sockets); + for (std::set<HttpServerSocket*>::const_iterator i = local.begin(); i != local.end(); ++i) { - httpsocks[i]->cull(); - delete httpsocks[i]; + HttpServerSocket* sock = *i; + sock->cull(); + delete sock; } + return Module::cull(); } virtual Version GetVersion() |