- 
                Notifications
    You must be signed in to change notification settings 
- Fork 48
Open
Description
- 问题代码&修复方案
// SwooleClient.php
   private function startRecvCo(): void
    {
        $this->coRecvRunning = true;
        $this->recvCoId = true;
        $this->recvCoId = Coroutine::create(function () {
            while ($this->coRecvRunning) {
                try {
                    $data = $this->socket->recv(4, -1);
                    if ($data === '') {
                        break;
                    }
                    $length = Int32::unpack($data);
                    $data = $this->socket->recv($length);
                    $correlationId = Int32::unpack($data);
                    if (isset($this->recvChannels[$correlationId])) {
                        $this->recvChannels[$correlationId]->push($data);
                    }
                } catch (Exception $e) {
                    if ($e instanceof SocketException && ! $this->connected) {
                        return;
                    }
                    $callback = $this->getConfig()->getExceptionCallback();
                    if ($callback) {
                        //  已经设置了 exception callback 没有退出就会一直死循环下去
                        $callback($e);
                        // 修复方案:在此次增加 return 
                        return;
                    } else {
                        throw $e;
                    }
                }
            }
        });
    }Metadata
Metadata
Assignees
Labels
No labels