diff options
author | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-11 04:24:37 +0000 |
---|---|---|
committer | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-11 04:24:37 +0000 |
commit | c662a37341e9787ca8c5e553b3d641a19e3b81c8 (patch) | |
tree | 9dede0e562bfa84059744340f66a316038f31750 /src/modules/extra/m_pgsql.cpp | |
parent | 0392e44ac5ba056bce4e36d54a88ee13ee61d3a8 (diff) |
pgsql should now work thx to added posibility to force a fd out of the socketengine. This should only be used as a *last resort* when dealing with 3rd party libs that invalidates a file descriptor beyond your control.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6295 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra/m_pgsql.cpp')
-rw-r--r-- | src/modules/extra/m_pgsql.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 602e1ce77..ae655495e 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -516,19 +516,25 @@ class SQLConn : public EventHandler Instance->Log(DEBUG, "Couldn't allocate PGconn structure, aborting: %s", PQerrorMessage(sql)); return false; } + if(PQstatus(sql) == CONNECTION_BAD) { Instance->Log(DEBUG, "PQconnectStart failed: %s", PQerrorMessage(sql)); return false; } + ShowStatus(); + if(PQsetnonblocking(sql, 1) == -1) { Instance->Log(DEBUG, "Couldn't set connection nonblocking: %s", PQerrorMessage(sql)); return false; } - this->fd = PQsocket(sql); + /* OK, we've initalised the connection, now to get it hooked into the socket engine + * and then start polling it. + */ + this->fd = PQsocket(sql); Instance->Log(DEBUG, "New SQL socket: %d", this->fd); if(this->fd <= -1) @@ -550,7 +556,6 @@ class SQLConn : public EventHandler bool DoPoll() { - ShowStatus(); switch(PQconnectPoll(sql)) { case PGRES_POLLING_WRITING: @@ -588,11 +593,9 @@ class SQLConn : public EventHandler */ idle = this->Instance->Time(); - ShowStatus(); - if(PQisBusy(sql)) { - Instance->Log(DEBUG, "Still busy processing command though"); + //Instance->Log(DEBUG, "Still busy processing command though"); } else if(qinprog) { @@ -661,7 +664,6 @@ class SQLConn : public EventHandler } else { - ShowStatus(); Instance->Log(DEBUG, "Eh!? We just got a read event, and connection isn't busy..but no result :("); } return true; @@ -688,7 +690,7 @@ class SQLConn : public EventHandler //ServerInstance->Log(DEBUG, "PGresetPoll: PGRES_POLLING_WRITING"); Instance->SE->WantWrite(this); status = CWRITE; - return DoResetPoll(); + return true; case PGRES_POLLING_READING: //ServerInstance->Log(DEBUG, "PGresetPoll: PGRES_POLLING_READING"); status = CREAD; @@ -710,14 +712,6 @@ class SQLConn : public EventHandler { switch(PQstatus(sql)) { - case CONNECTION_OK: - Instance->Log(DEBUG, "PQstatus: CONNECTION_OK: Ok."); - break; - - case CONNECTION_BAD: - Instance->Log(DEBUG, "PQstatus: CONNECTION_BAD: Bad."); - break; - case CONNECTION_STARTED: Instance->Log(DEBUG, "PQstatus: CONNECTION_STARTED: Waiting for connection to be made."); break; @@ -943,7 +937,7 @@ class SQLConn : public EventHandler Instance->Log(DEBUG,"SQLConn::Close"); Instance->Log(DEBUG, "FD IS: %d", this->fd); - if (!this->Instance->SE->DelFd(this)) + if (!this->Instance->SE->DelFd(this, true)) { Instance->Log(DEBUG, "PQsocket cant be removed from the socket engine!"); } |