summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2020-04-23 13:24:26 +0100
committerSadie Powell <sadie@witchery.services>2020-04-23 16:12:08 +0100
commitb24a91181f58c7f7141de8995ff212993bcc333b (patch)
tree8c6198de361ca7f5f7a03a02ee9b16c37c2d13f7
parent426d1c8e7ef6186fa122477bb51f8e6023dda56b (diff)
Opt-out of pgsql read and write events if polling fails.
-rw-r--r--src/modules/extra/m_pgsql.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index c454befae..916f164d1 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -57,6 +57,9 @@ typedef insp::flat_map<std::string, SQLConn*> ConnMap;
enum SQLstatus
{
+ // The connection has died.
+ DEAD,
+
// Connecting and wants read event.
CREAD,
@@ -310,6 +313,8 @@ class SQLConn : public SQL::Provider, public EventHandler
status = CREAD;
return true;
case PGRES_POLLING_FAILED:
+ SocketEngine::ChangeEventMask(this, FD_WANT_NO_READ | FD_WANT_NO_WRITE);
+ status = DEAD;
return false;
case PGRES_POLLING_OK:
SocketEngine::ChangeEventMask(this, FD_WANT_POLL_READ | FD_WANT_NO_WRITE);
@@ -399,7 +404,7 @@ restart:
{
DoPoll();
}
- else
+ else if (status == WREAD || status == WWRITE)
{
DoConnectedPoll();
}
@@ -500,6 +505,7 @@ restart:
void Close()
{
+ status = DEAD;
SocketEngine::DelFd(this);
if(sql)
@@ -612,6 +618,7 @@ bool ReconnectTimer::Tick(time_t time)
void SQLConn::DelayReconnect()
{
+ status = DEAD;
ModulePgSQL* mod = (ModulePgSQL*)(Module*)creator;
ConnMap::iterator it = mod->connections.find(conf->getString("id"));
if (it != mod->connections.end())