From a70a541e0b6d9eed7979b7fee04eb5ec682fd436 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sun, 3 May 2015 11:44:10 +0100 Subject: [PATCH] Unlock the connection after PQflush error Apparently this has never happened... anyway the code path was wrong. Fixes #294. --- NEWS | 1 + psycopg/pqpath.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 0b71653f..86751c4f 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ Current release What's new in psycopg 2.6.1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- Correctly unlock the connection after error in flush (:ticket:`#294`). - Fixed ``MinTimeLoggingCursor.callproc()`` (:ticket:`#309`). diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index c4b5528d..5e1974be 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -980,6 +980,10 @@ pq_execute(cursorObject *curs, const char *query, int async, int no_result, int } else { /* there was an error */ + pthread_mutex_unlock(&(curs->conn->lock)); + Py_BLOCK_THREADS; + PyErr_SetString(OperationalError, + PQerrorMessage(curs->conn->pgconn)); return -1; } }