diff options
| author | 2020-04-23 16:15:03 +0100 | |
|---|---|---|
| committer | 2020-04-24 11:48:45 +0100 | |
| commit | 07d7dea334fc56642793aa5ae1e05ae3185c474b (patch) | |
| tree | 01b4722fcba62f416e38d3493013796bba78a767 /src/modules/extra/m_pgsql.cpp | |
| parent | Unregister pgsql connection fds when they are deleted. (diff) | |
Fix reconnecting a pgsql connection if it fails.
Diffstat (limited to 'src/modules/extra/m_pgsql.cpp')
| -rw-r--r-- | src/modules/extra/m_pgsql.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index db999582f..c4241a495 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -549,8 +549,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 { @@ -616,16 +621,16 @@ 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); } } |
