From 1638ee61936bc91758be39c3463c6e46d0d655e7 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Tue, 9 Apr 2013 23:51:06 +0200 Subject: Timer changes and TimerManager enhancements Timer::Tick() now has a bool return value: if false is returned the timer is deleted using operator delete, otherwise, if it's a repeating timer then it's rescheduled (readded) Timers are removed from the TimerManager automatically at destruction Timers are now stored in a multimap instead of a sorted vector --- src/inspsocket.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/inspsocket.cpp') diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index fdd002ad6..5f2da2341 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -431,12 +431,12 @@ void StreamSocket::WriteData(const std::string &data) ServerInstance->SE->ChangeEventMask(this, FD_ADD_TRIAL_WRITE); } -void SocketTimeout::Tick(time_t) +bool SocketTimeout::Tick(time_t) { ServerInstance->Logs->Log("SOCKET", LOG_DEBUG,"SocketTimeout::Tick"); if (ServerInstance->SE->GetRef(this->sfd) != this->sock) - return; + return false; if (this->sock->state == I_CONNECTING) { @@ -452,6 +452,7 @@ void SocketTimeout::Tick(time_t) } this->sock->Timeout = NULL; + return false; } void BufferedSocket::OnConnected() { } @@ -476,8 +477,8 @@ BufferedSocket::~BufferedSocket() this->Close(); if (Timeout) { - ServerInstance->Timers->DelTimer(Timeout); - Timeout = NULL; + // The timer is removed from the TimerManager in Timer::~Timer() + delete Timeout; } } -- cgit v1.3.1-10-gc9f91