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

swoole 升级之后不再支持旧版本的队列 #3442

Closed LeiZhang-Hunter closed 4 years ago

LeiZhang-Hunter commented 4 years ago

我们来看swoole_framework的队列代码

    for ($i = 0; $i < $worker_num; $i++)
    {
        $process = new \SPF\process(array($this, '_worker'), false, false);
        $process->start();
        $this->_workers[] = $process;
    }

    \swoole_process::signal(SIGCHLD, function() {
        while(true) {
            $exitProcess = \swoole_process::wait(false);
            if ($exitProcess)
            {
                foreach ($this->_workers as $k => $p)
                {
                    if ($p->pid == $exitProcess['pid'])
                    {
                        if ($this->_atomic->get() == 1)
                        {
                            $p->start();
                        }
                        else
                        {
                            unset($this->_workers[$k]);
                            if (count($this->_workers) == 0)
                            {
                                swoole_event_exit();
                            }
                        }
                    }
                }
            }
            else
            {
                break;
            }
        }
    });

旧版本的swoole,在start之后如注册了signalfd 是会有epoll循环做监听的,升级了之后显示的事件循环变成了隐式的,会导致主进程程序直接退出

twose commented 4 years ago

[自动回复] 为了中文搜索引擎收录以便于后人检索和Github各国友人参与理解所需,本repo只接受英文issue

中文issue请前往Swoole中文问答社区

谢谢合作!