From 300b27d0bb035c11b81c2e07541b5c194b1f9031 Mon Sep 17 00:00:00 2001 From: peavey Date: Thu, 11 Jan 2007 04:39:51 +0000 Subject: Only use force if necessary! Tidy up debug output. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6296 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_pgsql.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index ae655495e..fc383d4e9 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -690,7 +690,7 @@ class SQLConn : public EventHandler //ServerInstance->Log(DEBUG, "PGresetPoll: PGRES_POLLING_WRITING"); Instance->SE->WantWrite(this); status = CWRITE; - return true; + return DoPoll(); case PGRES_POLLING_READING: //ServerInstance->Log(DEBUG, "PGresetPoll: PGRES_POLLING_READING"); status = CREAD; @@ -712,6 +712,14 @@ class SQLConn : public EventHandler { switch(PQstatus(sql)) { + case CONNECTION_OK: + Instance->Log(DEBUG, "PQstatus: CONNECTION_OK: Can proceed to connect."); + break; + + case CONNECTION_BAD: + Instance->Log(DEBUG, "PQstatus: CONNECTION_BAD: Connection is closed."); + break; + case CONNECTION_STARTED: Instance->Log(DEBUG, "PQstatus: CONNECTION_STARTED: Waiting for connection to be made."); break; @@ -934,16 +942,24 @@ class SQLConn : public EventHandler void DoClose() { - Instance->Log(DEBUG,"SQLConn::Close"); - Instance->Log(DEBUG, "FD IS: %d", this->fd); + Instance->Log(DEBUG, "SQLConn::Close - socket: %d", this->fd); - if (!this->Instance->SE->DelFd(this, true)) + if (!this->Instance->SE->DelFd(this)) { - Instance->Log(DEBUG, "PQsocket cant be removed from the socket engine!"); + if (sql && PQstatus(sql) == CONNECTION_BAD) + { + Instance->Log(DEBUG, "PQsocket was already removed. Forcing removal from the socket engine!"); + this->Instance->SE->DelFd(this, true); + } + else + { + Instance->Log(DEBUG, "PQsocket cant be removed from the socket engine!"); + } } else { - Instance->Log(DEBUG, "FD WAS REMOVED!"); + Instance->Log(DEBUG, "PQsocket could not be removed!"); } + if(sql) { PQfinish(sql); -- cgit v1.2.3