summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/extra/m_pgsql.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index c64017d61..2645617a5 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -554,8 +554,13 @@ class ModulePgSQL : public Module
if (curr == connections.end())
{
SQLConn* conn = new SQLConn(this, i->second);
- conns.insert(std::make_pair(id, conn));
- ServerInstance->Modules->AddService(*conn);
+ if (conn->status != DEAD)
+ {
+ conns.insert(std::make_pair(id, conn));
+ ServerInstance->Modules->AddService(*conn);
+ }
+ // If the connection is dead it has already been queued for culling
+ // at the end of the main loop so we don't need to delete it here.
}
else
{
@@ -623,16 +628,15 @@ void SQLConn::DelayReconnect()
{
status = DEAD;
ModulePgSQL* mod = (ModulePgSQL*)(Module*)creator;
+
ConnMap::iterator it = mod->connections.find(conf->getString("id"));
if (it != mod->connections.end())
- {
mod->connections.erase(it);
- ServerInstance->GlobalCulls.AddItem((EventHandler*)this);
- if (!mod->retimer)
- {
- mod->retimer = new ReconnectTimer(mod);
- ServerInstance->Timers.AddTimer(mod->retimer);
- }
+ ServerInstance->GlobalCulls.AddItem((EventHandler*)this);
+ if (!mod->retimer)
+ {
+ mod->retimer = new ReconnectTimer(mod);
+ ServerInstance->Timers.AddTimer(mod->retimer);
}
}