GIL-related fixes.

This commit is contained in:
Federico Di Gregorio 2005-03-29 06:00:38 +00:00
parent 75e7273d85
commit f4ad71fc1d
2 changed files with 10 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2005-03-29 Federico Di Gregorio <fog@debian.org>
* psycopg/pqpath.c (pq_is_busy): Staring from bug report from
Jason Erickson fixed segfaults due to calling Python function
without holding the GIL.
2005-03-24 Federico Di Gregorio <fog@debian.org>
* psycopg/typecast_array.c (typecast_array_tokenize): much better

View File

@ -321,12 +321,15 @@ pq_is_busy(connectionObject *conn)
if (PQconsumeInput(conn->pgconn) == 0) {
Dprintf("pq_is_busy: PQconsumeInput() failed");
PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn));
pthread_mutex_unlock(&(conn->lock));
Py_BLOCK_THREADS;
PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn));
return -1;
}
pthread_mutex_unlock(&(conn->lock));
Py_END_ALLOW_THREADS;
/* now check for notifies */
while ((pgn = PQnotifies(conn->pgconn)) != NULL) {
PyObject *notify;
@ -340,9 +343,6 @@ pq_is_busy(connectionObject *conn)
PyList_Append(conn->notifies, notify);
free(pgn);
}
pthread_mutex_unlock(&(conn->lock));
Py_END_ALLOW_THREADS;
return PQisBusy(conn->pgconn);
}