Skip to content

Move Disposal of QuicStream to the Http3Connection Prototype #102597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ internal sealed class Http3Connection : HttpConnectionBase
// Keep a collection of requests around so we can process GOAWAY.
private readonly Dictionary<QuicStream, Http3RequestStream> _activeRequests = new Dictionary<QuicStream, Http3RequestStream>();

internal readonly List<Task> _streamDisposals = [];

// Set when GOAWAY is being processed, when aborting, or when disposing.
private long _firstRejectedStreamId = -1;

Expand Down Expand Up @@ -126,6 +128,10 @@ private void CheckForShutdown()

if (_connection != null)
{
// Make sure we've disposed every stream before closing the connection.

Task.WhenAll(_streamDisposals).GetAwaiter().GetResult();

// Close the QuicConnection in the background.

_connectionClosedTask ??= _connection.CloseAsync((long)Http3ErrorCode.NoError).AsTask();
Expand Down Expand Up @@ -363,6 +369,14 @@ public void RemoveStream(QuicStream stream)
}
}

public void QueueStreamForDisposal(QuicStream stream)
{
lock (SyncObj)
{
_streamDisposals.Add(stream.DisposeAsync().AsTask());
}
}

public override long GetIdleTicks(long nowTicks) => throw new NotImplementedException("We aren't scavenging HTTP3 connections yet");

public override void Trace(string message, [CallerMemberName] string? memberName = null) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void Dispose()
{
_disposed = true;
AbortStream();
_stream.Dispose();
_connection.QueueStreamForDisposal(_stream);
DisposeSyncHelper();
}
}
Expand Down
Loading