From 0549bd85dea1911eec7e9758a0266cd7d24b4c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E3=80=81=E7=A7=8B=E7=A7=8B=E7=A7=8B=E7=A7=8B?= =?UTF-8?q?=E7=A7=8B=E7=A7=8B=E7=A7=8B?= <409703312@qq.com> Date: Sat, 18 Jan 2025 16:38:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E6=98=AF=E5=90=A6=E4=B8=BAnu?= =?UTF-8?q?ll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Connection/TcpConnection.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Connection/TcpConnection.php b/src/Connection/TcpConnection.php index e3536fd2..71def175 100644 --- a/src/Connection/TcpConnection.php +++ b/src/Connection/TcpConnection.php @@ -610,7 +610,9 @@ public function getRecvBufferQueueSize(): int */ public function pauseRecv(): void { - $this->eventLoop->offReadable($this->socket); + if($this->eventLoop !== null){ + $this->eventLoop->offReadable($this->socket); + } $this->isPaused = true; } @@ -1037,10 +1039,12 @@ public function destroy(): void return; } // Remove event listener. - $this->eventLoop->offReadable($this->socket); - $this->eventLoop->offWritable($this->socket); - if (DIRECTORY_SEPARATOR === '\\' && method_exists($this->eventLoop, 'offExcept')) { - $this->eventLoop->offExcept($this->socket); + if($this->eventLoop !== null){ + $this->eventLoop->offReadable($this->socket); + $this->eventLoop->offWritable($this->socket); + if (DIRECTORY_SEPARATOR === '\\' && method_exists($this->eventLoop, 'offExcept')) { + $this->eventLoop->offExcept($this->socket); + } } // Close socket.