diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2014-02-24 12:12:16 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2014-02-24 15:20:01 +0000 |
commit | 63e36e22d221b4707d37b9d5ec513058d9d8003f (patch) | |
tree | bfdb9e7a844e0a9a07a0d5f999a1a279420fd25a | |
parent | ca99579b76531735bc902ccc2a2656d7772b9e44 (diff) | |
download | psycopg2-63e36e22d221b4707d37b9d5ec513058d9d8003f.tar.gz |
Set the connection async before polling for connection
It should fix ticket #194
-rw-r--r-- | psycopg/connection_int.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 51ebfd2..c48dc81 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -613,6 +613,11 @@ _conn_async_connect(connectionObject *self) PQsetNoticeProcessor(pgconn, conn_notice_callback, (void*)self); + /* Set the connection to nonblocking now. */ + if (pq_set_non_blocking(self, 1) != 0) { + return -1; + } + /* The connection will be completed banging on poll(): * First with _conn_poll_connecting() that will finish connection, * then with _conn_poll_setup_async() that will do the same job @@ -787,11 +792,6 @@ _conn_poll_setup_async(connectionObject *self) switch (self->status) { case CONN_STATUS_CONNECTING: - /* Set the connection to nonblocking now. */ - if (pq_set_non_blocking(self, 1) != 0) { - break; - } - self->equote = conn_get_standard_conforming_strings(self->pgconn); self->protocol = conn_get_protocol_version(self->pgconn); self->server_version = conn_get_server_version(self->pgconn); |