From fa8f7290b23276a2903077da650e39906c3cdaa3 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Wed, 27 Nov 2024 23:11:36 -0600 Subject: [PATCH] Wait until all streams closed --- .../Internal/Http2ConnectionProcessor.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Connection/Internal/Http2ConnectionProcessor.php b/src/Connection/Internal/Http2ConnectionProcessor.php index 4eb8259d..41393197 100644 --- a/src/Connection/Internal/Http2ConnectionProcessor.php +++ b/src/Connection/Internal/Http2ConnectionProcessor.php @@ -1382,12 +1382,15 @@ private function releaseStream(int $streamId, ?\Throwable $exception, bool $unpr } } - if ($this->shutdown !== null && $streamId === $this->lastStream) { - $this->socket->close(); - } + if (!$this->streams) { + if ($this->shutdown !== null) { + $this->socket->close(); + return; + } - if (!$this->streams && !$this->socket->isClosed() && $this->socket instanceof ResourceStream) { - $this->socket->unreference(); + if ($this->socket instanceof ResourceStream) { + $this->socket->unreference(); + } } }