1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/pgsql: pg_cancel_query internal update.

Removing (obsolete) PGrequestCancel usage in favor of the thread-safe
 PQcancel/PQfreeCancel pair.

Close GH-11081
This commit is contained in:
David CARLIER
2023-04-15 14:53:42 +01:00
committed by David Carlier
parent a65cdd97a1
commit 84c185c8ba
2 changed files with 13 additions and 2 deletions

1
NEWS
View File

@@ -123,6 +123,7 @@ PHP NEWS
. pg_fetch_object raises a ValueError instead of an Exception.
(David Carlier)
. Added GH-9344, pipeline mode support. (David Carlier)
. pg_cancel use thread safe PQcancel api instead. (David Carlier)
- Phar:
. Fix memory leak in phar_rename_archive(). (stkeke)

View File

@@ -3470,12 +3470,22 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
PQconsumeInput(pgsql);
RETVAL_LONG(PQisBusy(pgsql));
break;
case PHP_PG_ASYNC_REQUEST_CANCEL:
RETVAL_LONG(PQrequestCancel(pgsql));
case PHP_PG_ASYNC_REQUEST_CANCEL: {
PGcancel *c;
char err[256];
int rc;
c = PQgetCancel(pgsql);
RETVAL_LONG((rc = PQcancel(c, err, sizeof(err))));
if (rc < 0) {
zend_error(E_WARNING, "cannot cancel the query: %s", err);
}
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
}
PQfreeCancel(c);
break;
}
EMPTY_SWITCH_DEFAULT_CASE()
}
if (PQsetnonblocking(pgsql, 0)) {