workerman 发现一个变量未定义 BUG: Events/Select.php, 请解决

zhouyongjin

PHP Fatal error: Uncaught ErrorException: Undefined variable: ret in /btc/okcoin/vendor/workerman/workerman/Events/Select.php:284

        while (1) {
            if(\DIRECTORY_SEPARATOR === '/') {
                // Calls signal handlers for pending signals
                \pcntl_signal_dispatch();
            }

            $read  = $this->_readFds;
            $write = $this->_writeFds;
            $except = $this->_exceptFds;

            if ($read || $write || $except) {
                // Waiting read/write/signal/timeout events.
                try {
                    $ret = @stream_select($read, $write, $except, 0, $this->_selectTimeout);
                } catch (\Exception $e) {} catch (\Error $e) {}

            } else {
                usleep($this->_selectTimeout);
                $ret = false;
            }

            if (!$this->_scheduler->isEmpty()) {
                $this->tick();
            }

=======>     if (!$ret) {
                continue;
            }

284行代码:

     if (!$ret) {

这个变量没有初始化, 当 try cache 发生异常时, 变量赋值语句没执行, 就会发生变量 未定义, 产生语法错误了。

2010 1 0
1个回答

walkor 打赏

感谢反馈。主干已经修复。

年代过于久远,无法发表回答
×
🔝