mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Grab the GIL when checking for errors occurred
The problem was causing a segfault on BEGIN if the server is disconnected after the connection is created.
This commit is contained in:
parent
d9fce1f837
commit
de6f2ac387
2
NEWS
2
NEWS
|
@ -1,6 +1,8 @@
|
||||||
What's new in psycopg 2.4.3
|
What's new in psycopg 2.4.3
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
- Fixed segfault in case of transaction started with connection lost
|
||||||
|
(and possibly other events).
|
||||||
- Lazy import of the slow uuid module, thanks to Marko Kreen.
|
- Lazy import of the slow uuid module, thanks to Marko Kreen.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -344,11 +344,13 @@ pq_execute_command_locked(connectionObject *conn, const char *query,
|
||||||
}
|
}
|
||||||
if (*pgres == NULL) {
|
if (*pgres == NULL) {
|
||||||
Dprintf("pq_execute_command_locked: PQexec returned NULL");
|
Dprintf("pq_execute_command_locked: PQexec returned NULL");
|
||||||
|
PyEval_RestoreThread(*tstate);
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
msg = PQerrorMessage(conn->pgconn);
|
msg = PQerrorMessage(conn->pgconn);
|
||||||
if (msg && *msg) { *error = strdup(msg); }
|
if (msg && *msg) { *error = strdup(msg); }
|
||||||
}
|
}
|
||||||
|
*tstate = PyEval_SaveThread();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,11 +637,13 @@ pq_get_guc_locked(
|
||||||
|
|
||||||
if (*pgres == NULL) {
|
if (*pgres == NULL) {
|
||||||
Dprintf("pq_get_guc_locked: PQexec returned NULL");
|
Dprintf("pq_get_guc_locked: PQexec returned NULL");
|
||||||
|
PyEval_RestoreThread(*tstate);
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
msg = PQerrorMessage(conn->pgconn);
|
msg = PQerrorMessage(conn->pgconn);
|
||||||
if (msg && *msg) { *error = strdup(msg); }
|
if (msg && *msg) { *error = strdup(msg); }
|
||||||
}
|
}
|
||||||
|
*tstate = PyEval_SaveThread();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (PQresultStatus(*pgres) != PGRES_TUPLES_OK) {
|
if (PQresultStatus(*pgres) != PGRES_TUPLES_OK) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user