Skip to content

Commit

Permalink
call exit using original function handler
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Oct 22, 2024
1 parent 021952c commit beed9c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext-src/swoole_coroutine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static int coro_exit_handler(zend_execute_data *execute_data) {
}
#else
SW_EXTERN_C_BEGIN
extern ZEND_FUNCTION(exit);
bool swoole_call_original_handler(const char *name, INTERNAL_FUNCTION_PARAMETERS);
PHP_FUNCTION(swoole_exit) {
zend_long flags = 0;
if (Coroutine::get_current()) {
Expand All @@ -251,7 +251,7 @@ 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);
swoole_call_original_handler("exit", INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
}
SW_EXTERN_C_END
Expand Down
12 changes: 12 additions & 0 deletions ext-src/swoole_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,18 @@ static bool enable_func(const char *name, size_t l_name) {
return true;
}

SW_EXTERN_C_BEGIN
bool swoole_call_original_handler(const char *name, INTERNAL_FUNCTION_PARAMETERS) {
real_func *rf = (real_func *) zend_hash_str_find_ptr(tmp_function_table, name, strlen(name));
if (!rf) {
return false;
}
rf->ori_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);

return true;
}
SW_EXTERN_C_END

void PHPCoroutine::disable_unsafe_function() {
for (auto &f : unsafe_functions) {
disable_func(f.c_str(), f.length());
Expand Down

0 comments on commit beed9c3

Please sign in to comment.