Skip to content

Commit

Permalink
Account for server window changes when discarding data frames
Browse files Browse the repository at this point in the history
If streams are cancelled, this might result in hanging connections, because the client thinks the server window is still large enough and doesn't increase it.
  • Loading branch information
kelunik committed Nov 8, 2020
1 parent 2af4024 commit 9edc51f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Connection/Internal/Http2ConnectionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,12 @@ public function handleConnectionException(Http2ConnectionException $exception):

public function handleData(int $streamId, string $data): void
{
$length = \strlen($data);

$this->serverWindow -= $length;

$this->increaseConnectionWindow();

if (!isset($this->streams[$streamId])) {
return;
}
Expand All @@ -815,9 +821,6 @@ public function handleData(int $streamId, string $data): void
return;
}

$length = \strlen($data);

$this->serverWindow -= $length;
$stream->serverWindow -= $length;
$stream->received += $length;

Expand All @@ -841,8 +844,6 @@ public function handleData(int $streamId, string $data): void
return;
}

$this->increaseConnectionWindow();

$promise = $stream->body->emit($data);
$promise->onResolve(function (?\Throwable $exception) use ($streamId): void {
if ($exception || !isset($this->streams[$streamId])) {
Expand Down

0 comments on commit 9edc51f

Please sign in to comment.