From 8ddaec4fe598fdf718f0209050d4c3d635d21b79 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 22 Oct 2024 10:45:16 +0200 Subject: [PATCH] call exit using call_user_function --- ext-src/swoole_coroutine.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ext-src/swoole_coroutine.cc b/ext-src/swoole_coroutine.cc index eb7c13abb4e..552c5ec92c1 100644 --- a/ext-src/swoole_coroutine.cc +++ b/ext-src/swoole_coroutine.cc @@ -251,7 +251,23 @@ PHP_FUNCTION(swoole_exit) { zend_update_property_long(swoole_exit_exception_ce, SW_Z8_OBJ_P(&ex), ZEND_STRL("flags"), flags); zend_update_property_long(swoole_exit_exception_ce, SW_Z8_OBJ_P(&ex), ZEND_STRL("status"), status); } else { - ZEND_FN(exit)(INTERNAL_FUNCTION_PARAM_PASSTHRU); + zval exit_fn_name; + zval ret; + zval *msg_or_code = NULL; + + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL(msg_or_code) + ZEND_PARSE_PARAMETERS_END(); + + ZVAL_STRING(&exit_fn_name, "exit"); + + if (msg_or_code) { + call_user_function(EG(function_table), NULL, &exit_fn_name, &ret, 1, msg_or_code); + } else { + call_user_function(EG(function_table), NULL, &exit_fn_name, &ret, 0, NULL); + } + zval_ptr_dtor(&exit_fn_name); } } SW_EXTERN_C_END