Fix slow shutdown when a Streamable HTTP client is connected (#843)

* Add "Async" suffix to async methods
This commit is contained in:
Stephen Halter 2025-10-10 17:50:57 -07:00 • committed by GitHub
commit e01edc143a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,7 +13,11 @@ public sealed class KestrelInMemoryTransport : IConnectionListenerFactory
public KestrelInMemoryConnection CreateConnection(EndPoint endpoint)
{
var connection = new KestrelInMemoryConnection();
GetAcceptQueue(endpoint).Writer.TryWrite(connection);
if (!GetAcceptQueue(endpoint).Writer.TryWrite(connection))
{
throw new IOException("The KestrelInMemoryTransport has been shut down.");
};
return connection;
}
@ -37,12 +41,9 @@ public sealed class KestrelInMemoryTransport : IConnectionListenerFactory
public async ValueTask<ConnectionContext?> AcceptAsync(CancellationToken cancellationToken = default)
{
if (await acceptQueue.Reader.WaitToReadAsync(cancellationToken))
await foreach (var item in acceptQueue.Reader.ReadAllAsync(cancellationToken))
{
while (acceptQueue.Reader.TryRead(out var item))
{
return item;
}
return item;
}
return null;