From fa4efb47656f1fb3c5271652f198f53b175530c8 Mon Sep 17 00:00:00 2001 From: matyhtf Date: Wed, 25 Sep 2024 14:04:43 +0800 Subject: [PATCH] fix tests --- ext-src/swoole_coroutine_scheduler.cc | 2 +- ext-src/swoole_server.cc | 4 ++-- ext-src/swoole_server_port.cc | 6 ++---- tests/swoole_http_server/callback_with_private.phpt | 6 +----- tests/swoole_http_server/callback_with_protected.phpt | 6 +----- 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/ext-src/swoole_coroutine_scheduler.cc b/ext-src/swoole_coroutine_scheduler.cc index c9713749c2b..06a37b7808f 100644 --- a/ext-src/swoole_coroutine_scheduler.cc +++ b/ext-src/swoole_coroutine_scheduler.cc @@ -136,8 +136,8 @@ void php_swoole_coroutine_scheduler_rshutdown() { }); if (exit_condition_fci_cache) { - exit_condition_fci_cache = nullptr; sw_zend_fci_cache_free(exit_condition_fci_cache); + exit_condition_fci_cache = nullptr; } } diff --git a/ext-src/swoole_server.cc b/ext-src/swoole_server.cc index 01af10709ec..2d98531bf5f 100644 --- a/ext-src/swoole_server.cc +++ b/ext-src/swoole_server.cc @@ -209,7 +209,7 @@ static void server_free_object(zend_object *object) { for (int i = 0; i < PHP_SWOOLE_SERVER_CALLBACK_NUM; i++) { zend_fcall_info_cache *fci_cache = property->callbacks[i]; if (fci_cache) { - efree(fci_cache); + sw_zend_fci_cache_free(fci_cache); property->callbacks[i] = nullptr; } } @@ -2424,7 +2424,7 @@ static PHP_METHOD(swoole_server, on) { swoole_server_ce, SW_Z8_OBJ_P(ZEND_THIS), property_name.c_str(), property_name.length(), cb); if (server_object->property->callbacks[event_type]) { - efree(server_object->property->callbacks[event_type]); + sw_zend_fci_cache_free(server_object->property->callbacks[event_type]); } auto fci_cache = sw_zend_fci_cache_create(cb); diff --git a/ext-src/swoole_server_port.cc b/ext-src/swoole_server_port.cc index 3e8c8554e33..e3551ee13b6 100644 --- a/ext-src/swoole_server_port.cc +++ b/ext-src/swoole_server_port.cc @@ -94,7 +94,7 @@ void php_swoole_server_port_deref(zend_object *object) { if (property->serv) { for (int j = 0; j < PHP_SWOOLE_SERVER_PORT_CALLBACK_NUM; j++) { if (property->caches[j]) { - efree(property->caches[j]); + sw_zend_fci_cache_free(property->caches[j]); property->caches[j] = nullptr; } } @@ -191,8 +191,6 @@ void php_swoole_server_port_minit(int module_number) { * [Master/Worker] */ static ssize_t php_swoole_server_length_func(const Protocol *protocol, network::Socket *conn, PacketLength *pl) { - Server *serv = (Server *) protocol->private_data_2; - zend_fcall_info_cache *fci_cache = (zend_fcall_info_cache *) protocol->private_data; zval zdata; zval retval; @@ -622,7 +620,7 @@ static PHP_METHOD(swoole_server_port, on) { sw_zend_read_property(swoole_server_port_ce, ZEND_THIS, property_name.c_str(), property_name.length(), 0); sw_copy_to_stack(property->callbacks[index], property->_callbacks[index]); if (property->caches[index]) { - efree(property->caches[index]); + sw_zend_fci_cache_free(property->caches[index]); } auto fci_cache = sw_zend_fci_cache_create(cb); diff --git a/tests/swoole_http_server/callback_with_private.phpt b/tests/swoole_http_server/callback_with_private.phpt index d5b5ecae0db..e436119df06 100644 --- a/tests/swoole_http_server/callback_with_private.phpt +++ b/tests/swoole_http_server/callback_with_private.phpt @@ -38,10 +38,6 @@ $pm->run(true); //Fatal Error $pm->expectExitCode(255); $output = $pm->getChildOutput(); -if (PHP_VERSION_ID < 80000) { - Assert::contains($output, 'Swoole\Server::on() must be callable'); -} else { - Assert::contains($output, 'Swoole\Server::on(): function \'TestCo_9::foo\' is not callable'); -} +Assert::contains($output, "Swoole\Server\Port::on(): function 'TestCo_9::foo' is not callable"); ?> --EXPECT-- diff --git a/tests/swoole_http_server/callback_with_protected.phpt b/tests/swoole_http_server/callback_with_protected.phpt index 0af346d91d2..bf645080af7 100644 --- a/tests/swoole_http_server/callback_with_protected.phpt +++ b/tests/swoole_http_server/callback_with_protected.phpt @@ -34,10 +34,6 @@ $pm = ProcessManager::exec(function ($pm) { //Fatal Error $pm->expectExitCode(255); $output = $pm->getChildOutput(); -if (PHP_VERSION_ID < 80000) { - Assert::contains($output, 'Swoole\Server::on() must be callable'); -} else { - Assert::contains($output, 'Swoole\Server::on(): function \'TestCo::foo\' is not callable'); -} +Assert::contains($output, 'Swoole\Server\Port::on(): function \'TestCo::foo\' is not callable'); ?> --EXPECT--