From: Michael Wallner Date: Fri, 8 Feb 2013 22:09:31 +0000 (+0100) Subject: cancel any active async query on persistent connection retirement X-Git-Tag: v0.1.0~16 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=commitdiff_plain;h=86e7a4a14c80824b25074743e1acae0c2f0fc0e8 cancel any active async query on persistent connection retirement --- 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);