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");