Skip to content

Commit

Permalink
Rearrange
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Nov 28, 2024
1 parent ca88b1d commit f712bd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/Connection/Internal/Http2ConnectionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,8 @@ public function isClosed(): bool

private function runReadFiber(): void
{
$parser = new Http2Parser($this, $this->hpack);

try {
$this->frameQueue->push(Http2Parser::PREFACE);

Expand All @@ -1092,19 +1094,7 @@ private function runReadFiber(): void
self::DEFAULT_MAX_FRAME_SIZE
)
)->await();
} catch (\Throwable $exception) {
$this->shutdown(new SocketException(
"The HTTP/2 connection closed" . ($this->shutdown !== null ? ' unexpectedly' : ''),
$this->shutdown ?? Http2Parser::GRACEFUL_SHUTDOWN,
$exception,
), 0);

return;
}

$parser = new Http2Parser($this, $this->hpack);

try {
while (null !== $chunk = $this->socket->read()) {
$parser->push($chunk);
}
Expand All @@ -1115,8 +1105,6 @@ private function runReadFiber(): void
Http2Parser::INTERNAL_ERROR,
$exception,
));

return;
} finally {
$parser->cancel();

Expand All @@ -1132,9 +1120,9 @@ private function runReadFiber(): void
}

$this->frameQueue->complete();
}

$this->shutdown();
$this->shutdown();
}
}

private function writeFrame(
Expand Down
2 changes: 2 additions & 0 deletions test/Connection/Http2ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ public function testServerGoAwayFrame(): void

$this->server->write(self::packFrame('test', Http2Parser::DATA, Http2Parser::END_STREAM, 1));

delay(0.1);

$this->server->close();
});

Expand Down

0 comments on commit f712bd3

Please sign in to comment.