summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2021-06-03 00:06:31 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2021-06-03 00:06:31 +0100
commit22af61bc31b9d973ad518e1a094c25328082b0be (patch)
tree2df37da565cb9523cf8a36df1297acecf8554cc1
parent359679b13606de45931cd4b4ccb1db20a1c339f1 (diff)
downloadpsycopg2-fix-1248.tar.gz
Fix concurrent use of conection.poll()fix-1248
Close #1248
-rw-r--r--NEWS1
-rw-r--r--psycopg/connection_int.c6
2 files changed, 7 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 5b3dab3..3c6ba19 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Current release
What's new in psycopg 2.8.7
^^^^^^^^^^^^^^^^^^^^^^^^^^^
+- Fix concurrent use of `!conection.poll()` (:ticket:`1248`).
- Accept empty params as `~psycopg2.connect()` (:ticket:`#1250`).
- Fix attributes refcount in `Column` initialisation (:ticket:`#1252`).
- Allow re-initialisation of static variables in the C module (:ticket:`#1267`).
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c
index da8a464..d0775ec 100644
--- a/psycopg/connection_int.c
+++ b/psycopg/connection_int.c
@@ -904,8 +904,14 @@ _conn_poll_advance_read(connectionObject *self)
Dprintf("conn_poll: poll reading");
+ Py_BEGIN_ALLOW_THREADS;
+ pthread_mutex_lock(&(self->lock));
+
busy = pq_get_result_async(self);
+ pthread_mutex_unlock(&(self->lock));
+ Py_END_ALLOW_THREADS;
+
switch (busy) {
case 0: /* result is ready */
Dprintf("conn_poll: async_status -> ASYNC_DONE");