mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 21:00:33 +03:00
Don't call CLEARPGRES on the cursor state without holding the gil
There is a chance it is executed by two different threads resulting in issue #384. I havent't found any other case that may lead to double free.
This commit is contained in:
parent
ddcf808d56
commit
07d9fb8718
|
@ -1016,6 +1016,8 @@ pq_execute(cursorObject *curs, const char *query, int async, int no_result, int
|
|||
}
|
||||
Dprintf("pq_execute: pg connection at %p OK", curs->conn->pgconn);
|
||||
|
||||
CLEARPGRES(curs->pgres);
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS;
|
||||
pthread_mutex_lock(&(curs->conn->lock));
|
||||
|
||||
|
@ -1027,7 +1029,6 @@ pq_execute(cursorObject *curs, const char *query, int async, int no_result, int
|
|||
}
|
||||
|
||||
if (async == 0) {
|
||||
CLEARPGRES(curs->pgres);
|
||||
Dprintf("pq_execute: executing SYNC query: pgconn = %p", curs->conn->pgconn);
|
||||
Dprintf(" %-.200s", query);
|
||||
if (!psyco_green()) {
|
||||
|
@ -1069,7 +1070,6 @@ pq_execute(cursorObject *curs, const char *query, int async, int no_result, int
|
|||
Dprintf("pq_execute: executing ASYNC query: pgconn = %p", curs->conn->pgconn);
|
||||
Dprintf(" %-.200s", query);
|
||||
|
||||
CLEARPGRES(curs->pgres);
|
||||
if (PQsendQuery(curs->conn->pgconn, query) == 0) {
|
||||
if (CONNECTION_BAD == PQstatus(curs->conn->pgconn)) {
|
||||
curs->conn->closed = 2;
|
||||
|
|
Loading…
Reference in New Issue
Block a user