summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2020-04-23 16:15:03 +0100
committerSadie Powell <sadie@witchery.services>2020-04-23 16:41:15 +0100
commitb3f1db9d162455af4b31edf231ba749140d37219 (patch)
treecab3b83e216445ecdcc59ed615052e13913f661c
parentfbdd08043e97c2749ce2f03382559bba89abf47a (diff)
Fix reconnecting a pgsql connection if it fails.
-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);
}
}