Skip to content

Commit

Permalink
call exit using call_user_function
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Oct 22, 2024
1 parent 021952c commit 8ddaec4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion ext-src/swoole_coroutine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8ddaec4

Please sign in to comment.