diff options
Diffstat (limited to 'libpqpp/connection.cpp')
-rw-r--r-- | libpqpp/connection.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libpqpp/connection.cpp b/libpqpp/connection.cpp index 57531e3..de3f189 100644 --- a/libpqpp/connection.cpp +++ b/libpqpp/connection.cpp @@ -3,6 +3,7 @@ #include "selectcommand.h" #include "modifycommand.h" #include <unistd.h> +#include <poll.h> #include <boost/assert.hpp> NAMEDFACTORY("postgresql", PQ::Connection, DB::ConnectionFactory); @@ -108,7 +109,8 @@ PQ::Connection::bulkUpdateStyle() const void PQ::Connection::ping() const { - if (PQstatus(conn) != CONNECTION_OK) { + struct pollfd fd { PQsocket(conn), POLLRDHUP | POLLERR | POLLHUP | POLLNVAL, 0 }; + if (PQstatus(conn) != CONNECTION_OK || poll(&fd, 1, 1)) { if (inTx()) { throw ConnectionError(conn); } |