From 60130a933d8be97d0d6482aabc5e1ca5395855cc Mon Sep 17 00:00:00 2001 From: booo Date: Fri, 6 Jul 2012 14:22:59 +0200 Subject: [PATCH] check for CONNECTION_BAD status before calling PQsetnonblocking --- src/binding.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/binding.cc b/src/binding.cc index 62f0b2e..1e5ffc0 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -329,11 +329,6 @@ protected: LOG("Connection couldn't be created"); } - if (PQsetnonblocking(connection_, 1) == -1) { - LOG("Unable to set connection to non-blocking"); - return false; - } - ConnStatusType status = PQstatus(connection_); if(CONNECTION_BAD == status) { @@ -341,6 +336,11 @@ protected: return false; } + if (PQsetnonblocking(connection_, 1) == -1) { + LOG("Unable to set connection to non-blocking"); + return false; + } + int fd = PQsocket(connection_); if(fd < 0) { LOG("socket fd was negative. error");