Fix flaky StreamPool_StreamIsInvalidState_DontReturnedToPool (#20433)
This commit is contained in:
parent
5ac84db518
commit
53eaa8f106
|
|
@ -41,10 +41,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
|
||||||
private bool _suffixSent;
|
private bool _suffixSent;
|
||||||
private bool _streamEnded;
|
private bool _streamEnded;
|
||||||
private bool _writerComplete;
|
private bool _writerComplete;
|
||||||
private bool _disposed;
|
|
||||||
|
|
||||||
// Internal for testing
|
// Internal for testing
|
||||||
internal ValueTask _dataWriteProcessingTask;
|
internal ValueTask _dataWriteProcessingTask;
|
||||||
|
internal bool _disposed;
|
||||||
|
|
||||||
/// <summary>The core logic for the IValueTaskSource implementation.</summary>
|
/// <summary>The core logic for the IValueTaskSource implementation.</summary>
|
||||||
private ManualResetValueTaskSourceCore<FlushResult> _responseCompleteTaskSource = new ManualResetValueTaskSourceCore<FlushResult> { RunContinuationsAsynchronously = true }; // mutable struct, do not make this readonly
|
private ManualResetValueTaskSourceCore<FlushResult> _responseCompleteTaskSource = new ManualResetValueTaskSourceCore<FlushResult> { RunContinuationsAsynchronously = true }; // mutable struct, do not make this readonly
|
||||||
|
|
|
||||||
|
|
@ -486,12 +486,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
withStreamId: 1);
|
withStreamId: 1);
|
||||||
await WaitForStreamErrorAsync(1, Http2ErrorCode.INTERNAL_ERROR, null);
|
await WaitForStreamErrorAsync(1, Http2ErrorCode.INTERNAL_ERROR, null);
|
||||||
|
|
||||||
// Ping will trigger the stream to be returned to the pool so we can assert it
|
await PingUntilStreamDisposed(stream).DefaultTimeout();
|
||||||
await SendPingAsync(Http2PingFrameFlags.NONE);
|
|
||||||
await ExpectAsync(Http2FrameType.PING,
|
|
||||||
withLength: 8,
|
|
||||||
withFlags: (byte)Http2PingFrameFlags.ACK,
|
|
||||||
withStreamId: 0);
|
|
||||||
|
|
||||||
// Stream is not returned to the pool
|
// Stream is not returned to the pool
|
||||||
Assert.Equal(0, _connection.StreamPool.Count);
|
Assert.Equal(0, _connection.StreamPool.Count);
|
||||||
|
|
@ -500,6 +495,21 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
await output._dataWriteProcessingTask.DefaultTimeout();
|
await output._dataWriteProcessingTask.DefaultTimeout();
|
||||||
|
|
||||||
await StopConnectionAsync(expectedLastStreamId: 1, ignoreNonGoAwayFrames: false);
|
await StopConnectionAsync(expectedLastStreamId: 1, ignoreNonGoAwayFrames: false);
|
||||||
|
|
||||||
|
async Task PingUntilStreamDisposed(Http2Stream stream)
|
||||||
|
{
|
||||||
|
var output = (Http2OutputProducer)stream.Output;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// Ping will trigger the stream to be returned to the pool so we can assert it
|
||||||
|
await SendPingAsync(Http2PingFrameFlags.NONE);
|
||||||
|
await ExpectAsync(Http2FrameType.PING,
|
||||||
|
withLength: 8,
|
||||||
|
withFlags: (byte)Http2PingFrameFlags.ACK,
|
||||||
|
withStreamId: 0);
|
||||||
|
} while (!output._disposed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue