mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Close the connection if discovered bad on poll()
This commit is contained in:
parent
e5ab0b3987
commit
12c2fafa86
1
NEWS
1
NEWS
|
@ -12,6 +12,7 @@ What's new in psycopg 2.5.3
|
|||
the superclass init (:ticket:`#195`).
|
||||
- Mark the connection closed when a Socket connection is broken, as it
|
||||
happens for TCP connections instead (:ticket:`#196`).
|
||||
- Mark the connection closed if found broken on `poll()`.
|
||||
- It is now possible to call `get_transaction_status()` on closed connections.
|
||||
- Fixed debug build on Windows, thanks to James Emerton.
|
||||
|
||||
|
|
|
@ -807,6 +807,12 @@ pq_is_busy(connectionObject *conn)
|
|||
Dprintf("pq_is_busy: PQconsumeInput() failed");
|
||||
pthread_mutex_unlock(&(conn->lock));
|
||||
Py_BLOCK_THREADS;
|
||||
|
||||
/* if the libpq says pgconn is lost, close the py conn */
|
||||
if (CONNECTION_BAD == PQstatus(conn->pgconn)) {
|
||||
conn->closed = 2;
|
||||
}
|
||||
|
||||
PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn));
|
||||
return -1;
|
||||
}
|
||||
|
@ -836,6 +842,12 @@ pq_is_busy_locked(connectionObject *conn)
|
|||
|
||||
if (PQconsumeInput(conn->pgconn) == 0) {
|
||||
Dprintf("pq_is_busy_locked: PQconsumeInput() failed");
|
||||
|
||||
/* if the libpq says pgconn is lost, close the py conn */
|
||||
if (CONNECTION_BAD == PQstatus(conn->pgconn)) {
|
||||
conn->closed = 2;
|
||||
}
|
||||
|
||||
PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn));
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user