swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.47k stars 3.16k forks source link

SWOOLE_PROCESS don't work in FreeBSD #4838

Closed RicardoSette closed 2 years ago

RicardoSette commented 2 years ago

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error.
<?php

$http = new Swoole\Http\Server("127.0.0.1", 9501, SWOOLE_PROCESS);
$http->on('request', function ($request, $response) {
    $response->end("<h1>Hello Swoole. #".rand(1000, 9999)."</h1>");
});
$http->start();
  1. What did you expect to see?

response after cURL call in 127.0.0.1:9501

  1. What did you see instead?

noting, process locked

  1. What version of Swoole are you using (show your php --ri swoole)?
# php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.8.10
Built => Sep  5 2022 11:41:32
coroutine => enabled with boost asm context
eventfd => enabled
kqueue => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
zlib => 1.2.12
mutex_timedlock => enabled
pthread_barrier => enabled
mysqlnd => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 262144 => 262144
  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?
# php -v
PHP 7.4.30 (cli) (built: Sep  4 2022 01:24:05) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

# uname -a
FreeBSD freebsd-13-test 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC amd64

I also tested it on FreeBSD 12.3-RELEASE and PHP 7.4/8.0/8.1 versions. I tested versions of Swoole 4.8.10, 4.8.11, 4.8.12 and 5.0.0, with ports and pkg, but any recent version don't work in FreeBSD 12.3|13.1 with mode SWOOLE_PROCESS.

When the mode is SWOOLE_BASE correctly responds to the call, the failure occurs only in SWOOLE_PROCESS mode.

I tested it with Openswoole 4.11.1 and it works both modes(SWOOLE_PROCESS|SWOOLE_BASE) on FreeBSD 12.3-RELEASE and 13.1-RELEASE for PHP versions 7.4/8.0/8.1, only official Swoole don't works SWOOLE_PROCESS in FreeBSD.

RicardoSette commented 2 years ago

See if the data below helps to indicate the cause of the blocking of the request.

Tests with versions made available in the FreeBSD ports: 4.5.9(2021Q1) success 4.7.1(2021Q4) success 4.8.5(2022Q1) fails

So I did tests with sub versions of the 4.8.x series 4.8.0(17 Oct 2021) fails 4.8.1(30 Oct 2021) fails

The bug started in version 4.8.0.

2022Q1 - subversion 4.8.x
# php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.8.0
Built => Sep 23 2022 13:29:25
coroutine => enabled with boost asm context
eventfd => enabled
kqueue => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1o-freebsd  3 May 2022
dtls => enabled
http2 => enabled
zlib => 1.2.12
mutex_timedlock => enabled
pthread_barrier => enabled
mysqlnd => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 262144 => 262144

# curl --max-time 10 http://127.0.0.1:9501
curl: (28) Operation timed out after 10027 milliseconds with 0 bytes received