diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2021-06-03 00:06:31 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2021-06-03 00:06:31 +0100 |
commit | 22af61bc31b9d973ad518e1a094c25328082b0be (patch) | |
tree | 2df37da565cb9523cf8a36df1297acecf8554cc1 | |
parent | 359679b13606de45931cd4b4ccb1db20a1c339f1 (diff) | |
download | psycopg2-fix-1248.tar.gz |
Fix concurrent use of conection.poll()fix-1248
Close #1248
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | psycopg/connection_int.c | 6 |
2 files changed, 7 insertions, 0 deletions
@@ -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"); |