From 86e7a4a14c80824b25074743e1acae0c2f0fc0e8 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 8 Feb 2013 23:09:31 +0100 Subject: [PATCH] cancel any active async query on persistent connection retirement --- src/php_pq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/php_pq.c b/src/php_pq.c index 6223ef9..64d59af 100644 --- a/src/php_pq.c +++ b/src/php_pq.c @@ -1810,6 +1810,7 @@ static void php_pqconn_notice_ignore(void *p, const PGresult *res) static void php_pqconn_retire(php_persistent_handle_factory_t *f, void **handle TSRMLS_DC) { php_pqconn_event_data_t *evdata = PQinstanceData(*handle, php_pqconn_event); + PGcancel *cancel; PGresult *res; /* go away */ @@ -1818,6 +1819,11 @@ static void php_pqconn_retire(php_persistent_handle_factory_t *f, void **handle /* ignore notices */ PQsetNoticeReceiver(*handle, php_pqconn_notice_ignore, NULL); + /* cancel async queries */ + if (PQisBusy(*handle) && (cancel = PQgetCancel(*handle))) { + PQcancel(cancel, ZEND_STRL("retiring persistent connection")); + PQfreeCancel(cancel); + } /* clean up async results */ while ((res = PQgetResult(*handle))) { PHP_PQclear(res); -- 2.30.2