swoole / swoole-src

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

base 模式下个一个已经关闭的$fd发送内容会导致进程异常退出 #805

Closed breath-co2 closed 8 years ago

breath-co2 commented 8 years ago

用 BASE 模式启动,往一个已经close的连接上 send 内容会抛错后导致 worker 进程异常退出,而且不会自动重启进程,多进程模式下不存在这样的问题。

如果 worker 进程只有1个,则会 Segmentation fault: 11 后全部退出,错误内容如下:

[2016-08-08 17:54:30 *76970.0]  WARNING swReactorProcess_send2client: send[0] failed, session#1 has expired.
Segmentation fault: 11

如果有多个 worker 进程,则会报这样的错:

[2016-08-08 17:58:58 #77620.0]  WARNING swProcessPool_wait: [Manager]unknow worker[pid=-1]
matyhtf commented 8 years ago

swoole版本多少,我用最新的master分支代码进行测试无法重现。

breath-co2 commented 8 years ago

php:7.0.8, swoole: 1.8.8,系统:mac

matyhtf commented 8 years ago

最新的1.8.9代码测试无法重现core dump

qingxuanrk commented 7 years ago

[2017-04-23 23:44:23 #26114.0] WARNING swProcessPool_wait: [Manager]unknow worker[pid=26127] centos 5 , php 5.6, swoole-src为当前master 复现方式: server :

$serv = new swoole_server("0.0.0.0", 9501, SWOOLE_BASE, SWOOLE_SOCK_TCP);
$serv->set(array(
    'worker_num' => 3,
    'task_worker_num' => 2,
    'task_max_request' => 4,
    'dispatch_mode' => 2,
    "task_ipc_mode " => 2 ,
));

function my_onFinish($serv, $data)
{
}
function my_onStart($serv)
{
}
function my_onReceive($serv, $fd, $from_id, $data)
{
    $task_id = $serv->task($data, -1);
}
function my_onTask($serv, $task_id, $worker_id, $strData)
{
    sleep(1);
    return $strData;
}
function my_onFinish($serv, $data)
{
}
$serv->on('Start'       , 'my_onStart');
$serv->on('Receive'     , 'my_onReceive');
$serv->on('Task'        , 'my_onTask');
$serv->on('Finish'      , 'my_onFinish');

client

function demo() {
    $client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);
    $client->on("connect", function($cli) {
            $cli->send('swoole_clientinfo'.md5(mt_rand(10000,99999)));
            $cli->close();
    });

    $client->on("error", function($cli){
            echo "Connect failed\n";
    });

    $client->on("close", function($cli){
            echo "Connection close\n";
    });

    $client->connect('127.0.0.1', 9501, 0.5);
}
for ($i = 0; $i < 90; $i++) {
    demo();
}