-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Open
Description
不设置worker_num的时候可以正常解析,设置多个worker时会失败。
<?php
use Swoole\Coroutine;
use Swoole\Constant;
$http = new Swoole\Http\Server('0.0.0.0', 9501);
$http->set([
Constant::OPTION_WORKER_NUM => 2,
Constant::OPTION_HOOK_FLAGS => SWOOLE_HOOK_ALL,
]);
$http->on('Request', function ($request, $response) {
var_dump(gethostbyname('smtp.qq.com')); // 不开启hook时正常 hook后 false
var_dump(Coroutine\System::gethostbyname('smtp.qq.com')); // 均false
var_dump(swoole_last_error(), swoole_strerror(swoole_last_error(), 9));
var_dump(Coroutine\System::getaddrinfo('smtp.qq.com')); // 一直正常
$response->header('Content-Type', 'text/html; charset=utf-8');
$response->end('<h1>Hello Swoole. #' . rand(1000, 9999) . '</h1>');
});
$http->start();
PHP 8.4.6 (cli) (built: Apr 8 2025 19:55:31) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.6, Copyright (c) Zend Technologies
with Zend OPcache v8.4.6, Copyright (c), by Zend Technologies
$ php --ri swoole
swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 6.0.0
Built => Dec 17 2024 11:24:08
coroutine => enabled with boost asm context
kqueue => enabled
rwlock => enabled
openssl => OpenSSL 3.4.0 22 Oct 2024
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
c-ares => 1.34.4
zlib => 1.2.12
brotli => E16781312/D16781312
mysqlnd => enabled
Directive => Local Value => Master Value
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 262144 => 262144
Metadata
Metadata
Assignees
Labels
No labels