diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-03-05 02:47:52 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-03-05 02:47:52 +0000 |
commit | 37aa62ca52149360331e54740a2f70567343710e (patch) | |
tree | 8e1828649c9cdb330635445646e0528fd4586b2b /psycopg/connection_int.c | |
parent | b97599166ec218b474f45e9a81ac7f4d58f63b71 (diff) | |
parent | 84f2a370f6fc749aeb90628a0d0bdcf7f4b27048 (diff) | |
download | psycopg2-37aa62ca52149360331e54740a2f70567343710e.tar.gz |
Merge branch 'close-idempotent' into devel
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r-- | psycopg/connection_int.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 7046513..2395c00 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -906,6 +906,10 @@ conn_poll(connectionObject *self) void conn_close(connectionObject *self) { + if (self->closed) { + return; + } + /* sets this connection as closed even for other threads; also note that we need to check the value of pgconn, because we get called even when the connection fails! */ @@ -922,14 +926,13 @@ conn_close(connectionObject *self) * closed only in status CONN_STATUS_READY. */ - if (self->closed == 0) - self->closed = 1; + self->closed = 1; if (self->pgconn) { PQfinish(self->pgconn); - PQfreeCancel(self->cancel); - Dprintf("conn_close: PQfinish called"); self->pgconn = NULL; + Dprintf("conn_close: PQfinish called"); + PQfreeCancel(self->cancel); self->cancel = NULL; } |