Skip to content

Commit 60130a9

Browse files
committed
check for CONNECTION_BAD status before calling PQsetnonblocking
1 parent 125075b commit 60130a9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/binding.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,18 @@ class Connection : public ObjectWrap {
329329
LOG("Connection couldn't be created");
330330
}
331331

332-
if (PQsetnonblocking(connection_, 1) == -1) {
333-
LOG("Unable to set connection to non-blocking");
334-
return false;
335-
}
336-
337332
ConnStatusType status = PQstatus(connection_);
338333

339334
if(CONNECTION_BAD == status) {
340335
LOG("Bad connection status");
341336
return false;
342337
}
343338

339+
if (PQsetnonblocking(connection_, 1) == -1) {
340+
LOG("Unable to set connection to non-blocking");
341+
return false;
342+
}
343+
344344
int fd = PQsocket(connection_);
345345
if(fd < 0) {
346346
LOG("socket fd was negative. error");

0 commit comments

Comments
 (0)