diff --git a/composer.json b/composer.json index 3617e95..77c32f3 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "require": { "php": ">7.4", "ext-ffi": "*", - "symplely/zend-ffi": "~0.12.5" + "symplely/zend-ffi": "~0.12.7" }, "autoload": { "files": [ diff --git a/preload.php b/preload.php index 27b766d..a8220e0 100644 --- a/preload.php +++ b/preload.php @@ -328,7 +328,7 @@ function uv_ffi_loader() $version = \trim((string) $os['VERSION_ID']); if ($id === 'debian') { $code = $directory . 'headers/uv_ubuntu' . ((float)$version < 20.04 ? '18.04' : '20.04') . '.h'; - } elseif ($id === 'redhat') { + } elseif ($id === 'redhat' || $id === 'fedora') { $code = $directory . 'headers/uv_centos' . ((float)$version < 8 ? '7' : '8+') . '.h'; } } diff --git a/src/UVHandles.php b/src/UVHandles.php index e9d4e1b..6388c50 100644 --- a/src/UVHandles.php +++ b/src/UVHandles.php @@ -1475,36 +1475,37 @@ public static function init(...$arguments) $work_cb = \array_shift($arguments); $after_cb = \array_shift($arguments); $work = new static('struct uv_work_s'); - \zval_add_ref($work); $r = \uv_ffi()->uv_queue_work( $loop(), $work(), function (CData $req) use ($work_cb) { - // $tsrm_ls = \ze_ffi()->ts_resource_ex(0, null); - //$tsrm_ls = \ze_ffi()->tsrm_new_interpreter_context(); - //$old = \ze_ffi()->tsrm_set_interpreter_context($tsrm_ls); + require_once 'vendor/symplely/zend-ffi/preload.php'; + if (\IS_PHP8) { + \ze_ffi()->ts_resource_ex(0, null); + \tsrmls_cache_update(); + } else { + $tsrm_ls = \ze_ffi()->tsrm_new_interpreter_context(); + $old = \ze_ffi()->tsrm_set_interpreter_context($tsrm_ls); + } - // \zend_pg('expose_php', 0); - // \zend_pg('auto_globals_jit', 0); + \zend_pg('expose_php', 0); + \zend_pg('auto_globals_jit', 1); - // \ze_ffi()->php_request_startup(); - // \zend_eg('current_execute_data', null); - // \zend_eg('current_module', $phpext_uv_ptr); + \ze_ffi()->php_request_startup(); - // require_once 'vendor/symplely/zend-ffi/preload.php'; - // $work_cb(); + \zend_eg('current_execute_data', null); + $work_cb(); - //\ze_ffi()->php_request_shutdown(NULL); - // \ze_ffi()->ts_free_thread(); - // \ze_ffi()->tsrm_set_interpreter_context($old); - // \ze_ffi()->tsrm_free_interpreter_context($tsrm_ls); + if (\IS_PHP8) { + \ze_ffi()->ts_free_thread(); + } else { + \ze_ffi()->tsrm_set_interpreter_context($old); + \ze_ffi()->tsrm_free_interpreter_context($tsrm_ls); + } }, function (CData $req, int $status) use ($after_cb, $work) { - // $after_cb($status); - // unset($status); - // \FFI::free($req); - // \zval_del_ref($after_cb); - // \zval_del_ref($work); + $after_cb($status); + \zval_del_ref($work); } );