Skip to content

Commit

Permalink
[HTTP/2] Move away marking idle/non-idle from HttpConnectionPool (#10…
Browse files Browse the repository at this point in the history
…5876)

* Move away marking idle/non-idle from HttpConnectionPool

* Fix comment
  • Loading branch information
liveans authored Aug 2, 2024
1 parent d9fc0f1 commit f59a05e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,6 @@ public bool TryReserveStream()

if (_streamsInUse < _maxConcurrentStreams)
{
if (_streamsInUse == 0)
{
MarkConnectionAsNotIdle();
}

_streamsInUse++;
return true;
}
Expand Down Expand Up @@ -324,8 +319,6 @@ public void ReleaseStream()

if (_streamsInUse == 0)
{
MarkConnectionAsIdle();

if (_shutdown)
{
FinalTeardown();
Expand Down Expand Up @@ -1606,6 +1599,11 @@ private void AddStream(Http2Stream http2Stream)
ThrowRetry(SR.net_http_request_aborted);
}

if (_httpStreams.Count == 0)
{
MarkConnectionAsNotIdle();
}

// Now that we're holding the lock, configure the stream. The lock must be held while
// assigning the stream ID to ensure only one stream gets an ID, and it must be held
// across setting the initial window size (available credit) and storing the stream into
Expand Down Expand Up @@ -2072,6 +2070,11 @@ private void RemoveStream(Http2Stream http2Stream)
Debug.Fail($"Stream {http2Stream.StreamId} not found in dictionary during RemoveStream???");
return;
}

if (_httpStreams.Count == 0)
{
MarkConnectionAsIdle();
}
}

ReleaseStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,9 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
Action<RecordedCounter> check2 = connectionNoLongerIdle;
Action<RecordedCounter> check3 = connectionIsActive;

if (UseVersion.Major > 1)
if (UseVersion.Major > 2)
{
// With HTTP/2 and HTTP/3, the idle state change is emitted before RequestsQueueDuration.
// With HTTP/3, the idle state change is emitted before RequestsQueueDuration.
check1 = connectionNoLongerIdle;
check2 = connectionIsActive;
check3 = requestsQueueDuration;
Expand Down

0 comments on commit f59a05e

Please sign in to comment.