summaryrefslogtreecommitdiff
path: root/psycopg/connection_int.c
diff options
context:
space:
mode:
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r--psycopg/connection_int.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c
index c48dc81..aea2841 100644
--- a/psycopg/connection_int.c
+++ b/psycopg/connection_int.c
@@ -629,14 +629,23 @@ _conn_async_connect(connectionObject *self)
int
conn_connect(connectionObject *self, long int async)
{
- if (async == 1) {
+ int rv;
+
+ if (async == 1) {
Dprintf("con_connect: connecting in ASYNC mode");
- return _conn_async_connect(self);
+ rv = _conn_async_connect(self);
}
else {
Dprintf("con_connect: connecting in SYNC mode");
- return _conn_sync_connect(self);
+ rv = _conn_sync_connect(self);
+ }
+
+ if (rv != 0) {
+ /* connection failed, so let's close ourselves */
+ self->closed = 2;
}
+
+ return rv;
}