summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules/dns.h1
-rw-r--r--include/timer.h2
-rw-r--r--src/inspsocket.cpp4
-rw-r--r--src/modules/extra/m_pgsql.cpp1
-rw-r--r--src/timer.cpp5
5 files changed, 11 insertions, 2 deletions
diff --git a/include/modules/dns.h b/include/modules/dns.h
index 905e52a34..7f863fcca 100644
--- a/include/modules/dns.h
+++ b/include/modules/dns.h
@@ -185,6 +185,7 @@ namespace DNS
Query rr(*this);
rr.error = ERROR_TIMEDOUT;
this->OnError(&rr);
+ delete this;
return false;
}
};
diff --git a/include/timer.h b/include/timer.h
index 2887e2b52..503fa82a2 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -87,6 +87,8 @@ class CoreExport Timer
/** Called when the timer ticks.
* You should override this method with some useful code to
* handle the tick event.
+ * @param TIME The current time.
+ * @return True if the Timer object is still valid, false if it was destructed.
*/
virtual bool Tick(time_t TIME) = 0;
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index 798cde9b0..46f5bd3b2 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -440,7 +440,10 @@ bool SocketTimeout::Tick(time_t)
ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "SocketTimeout::Tick");
if (ServerInstance->SE->GetRef(this->sfd) != this->sock)
+ {
+ delete this;
return false;
+ }
if (this->sock->state == I_CONNECTING)
{
@@ -456,6 +459,7 @@ bool SocketTimeout::Tick(time_t)
}
this->sock->Timeout = NULL;
+ delete this;
return false;
}
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index 1ed5be6f0..b3b7d43df 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -593,6 +593,7 @@ bool ReconnectTimer::Tick(time_t time)
{
mod->retimer = NULL;
mod->ReadConf();
+ delete this;
return false;
}
diff --git a/src/timer.cpp b/src/timer.cpp
index f541c7eb1..b897056e6 100644
--- a/src/timer.cpp
+++ b/src/timer.cpp
@@ -47,8 +47,9 @@ void TimerManager::TickTimers(time_t TIME)
Timers.erase(i++);
if (!t->Tick(TIME))
- delete t;
- else if (t->GetRepeat())
+ continue;
+
+ if (t->GetRepeat())
{
t->SetTrigger(TIME + t->GetInterval());
AddTimer(t);