diff options
Diffstat (limited to 'src/modules/m_flashpolicyd.cpp')
-rw-r--r-- | src/modules/m_flashpolicyd.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/modules/m_flashpolicyd.cpp b/src/modules/m_flashpolicyd.cpp index 46fd33e61..6466a9fb2 100644 --- a/src/modules/m_flashpolicyd.cpp +++ b/src/modules/m_flashpolicyd.cpp @@ -28,15 +28,25 @@ namespace const std::string expected_request("<policy-file-request/>\0", 23); } -class FlashPDSocket : public BufferedSocket +class FlashPDSocket : public BufferedSocket, public Timer { - public: - time_t created; + /** True if this object is in the cull list + */ + bool waitingcull; - FlashPDSocket(int newfd) + bool Tick(time_t currtime) CXX11_OVERRIDE + { + AddToCull(); + return false; + } + + public: + FlashPDSocket(int newfd, unsigned int timeoutsec) : BufferedSocket(newfd) - , created(ServerInstance->Time()) + , Timer(timeoutsec) + , waitingcull(false) { + ServerInstance->Timers.AddTimer(this); } ~FlashPDSocket() @@ -58,10 +68,10 @@ class FlashPDSocket : public BufferedSocket void AddToCull() { - if (created == 0) + if (waitingcull) return; - created = 0; + waitingcull = true; Close(); ServerInstance->GlobalCulls.AddItem(this); } @@ -69,19 +79,9 @@ class FlashPDSocket : public BufferedSocket class ModuleFlashPD : public Module { - time_t timeout; + unsigned int timeout; public: - void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE - { - for (std::set<FlashPDSocket*>::const_iterator i = sockets.begin(); i != sockets.end(); ++i) - { - FlashPDSocket* sock = *i; - if ((sock->created + timeout <= curtime) && (sock->created != 0)) - sock->AddToCull(); - } - } - ModResult OnAcceptConnection(int nfd, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE { if (from->bind_tag->getString("type") != "flashpolicyd") @@ -90,7 +90,7 @@ class ModuleFlashPD : public Module if (policy_reply.empty()) return MOD_RES_DENY; - sockets.insert(new FlashPDSocket(nfd)); + sockets.insert(new FlashPDSocket(nfd, timeout)); return MOD_RES_ALLOW; } |