Skip to content

Commit c30a220

Browse files
committed
ext/pgsql: pg_cancel_query internal update.
Removing (obsolete) PGrequestCancel usage in favor of the thread-safe PQcancel/PQfreeCancel pair.
1 parent e2bd92f commit c30a220

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ext/pgsql/pgsql.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -3470,12 +3470,22 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
34703470
PQconsumeInput(pgsql);
34713471
RETVAL_LONG(PQisBusy(pgsql));
34723472
break;
3473-
case PHP_PG_ASYNC_REQUEST_CANCEL:
3474-
RETVAL_LONG(PQrequestCancel(pgsql));
3473+
case PHP_PG_ASYNC_REQUEST_CANCEL: {
3474+
PGcancel *c;
3475+
char err[256];
3476+
int rc;
3477+
3478+
c = PQgetCancel(pgsql);
3479+
RETVAL_LONG((rc = PQcancel(c, err, sizeof(err))));
3480+
if (rc < 0) {
3481+
zend_error(E_WARNING, "can't cancel the query: %s", err);
3482+
}
34753483
while ((pgsql_result = PQgetResult(pgsql))) {
34763484
PQclear(pgsql_result);
34773485
}
3486+
PQfreeCancel(c);
34783487
break;
3488+
}
34793489
EMPTY_SWITCH_DEFAULT_CASE()
34803490
}
34813491
if (PQsetnonblocking(pgsql, 0)) {

0 commit comments

Comments
 (0)