Skip to content

Commit 1172501

Browse files
authored
Fix graceful shutdown of connection close in HTTP/3 (#26638)
1 parent aed4e55 commit 1172501

31 files changed

+962
-344
lines changed

src/Servers/Kestrel/Core/src/CoreStrings.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,4 +641,10 @@ For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?l
641641
<data name="FailedToOpenCertStore" xml:space="preserve">
642642
<value>Failed to open certificate store {StoreName}.</value>
643643
</data>
644+
<data name="Http3ConnectionFaulted" xml:space="preserve">
645+
<value>The HTTP/3 connection faulted.</value>
646+
</data>
647+
<data name="Http3StreamAborted" xml:space="preserve">
648+
<value>The HTTP/3 request stream was aborted.</value>
649+
</data>
644650
</root>

src/Servers/Kestrel/Core/src/Http3Limits.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
1010
/// </summary>
1111
public class Http3Limits
1212
{
13-
private int _headerTableSize = 4096;
13+
private int _headerTableSize = 0;
1414
private int _maxRequestHeaderFieldSize = 8192;
1515

1616
/// <summary>
17-
/// Limits the size of the header compression table, in octets, the HPACK decoder on the server can use.
17+
/// Limits the size of the header compression table, in octets, the QPACK decoder on the server can use.
1818
/// <para>
19-
/// Value must be greater than 0, defaults to 4096
19+
/// Value must be greater than 0, defaults to 0.
2020
/// </para>
2121
/// </summary>
22-
public int HeaderTableSize
22+
// TODO: Make public https://github.com/dotnet/aspnetcore/issues/26666
23+
internal int HeaderTableSize
2324
{
2425
get => _headerTableSize;
2526
set

src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,44 +1558,6 @@ private async Task ReadInputAsync()
15581558
}
15591559
}
15601560

1561-
private class StreamCloseAwaitable : ICriticalNotifyCompletion
1562-
{
1563-
private static readonly Action _callbackCompleted = () => { };
1564-
1565-
// Initialize to completed so UpdateCompletedStreams runs at least once during connection teardown
1566-
// if there are still active streams.
1567-
private Action? _callback = _callbackCompleted;
1568-
1569-
public StreamCloseAwaitable GetAwaiter() => this;
1570-
public bool IsCompleted => ReferenceEquals(_callback, _callbackCompleted);
1571-
1572-
public void GetResult()
1573-
{
1574-
Debug.Assert(ReferenceEquals(_callback, _callbackCompleted));
1575-
1576-
_callback = null;
1577-
}
1578-
1579-
public void OnCompleted(Action continuation)
1580-
{
1581-
if (ReferenceEquals(_callback, _callbackCompleted) ||
1582-
ReferenceEquals(Interlocked.CompareExchange(ref _callback, continuation, null), _callbackCompleted))
1583-
{
1584-
Task.Run(continuation);
1585-
}
1586-
}
1587-
1588-
public void UnsafeOnCompleted(Action continuation)
1589-
{
1590-
OnCompleted(continuation);
1591-
}
1592-
1593-
public void Complete()
1594-
{
1595-
Interlocked.Exchange(ref _callback, _callbackCompleted)?.Invoke();
1596-
}
1597-
}
1598-
15991561
private enum RequestHeaderParsingState
16001562
{
16011563
Ready,

src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public ValueTask<FlushResult> WriteRstStreamAsync(int streamId, Http2ErrorCode e
547547
| Value (32) |
548548
+---------------------------------------------------------------+
549549
*/
550-
public ValueTask<FlushResult> WriteSettingsAsync(IList<Http2PeerSetting> settings)
550+
public ValueTask<FlushResult> WriteSettingsAsync(List<Http2PeerSetting> settings)
551551
{
552552
lock (_writeLock)
553553
{
@@ -569,7 +569,7 @@ public ValueTask<FlushResult> WriteSettingsAsync(IList<Http2PeerSetting> setting
569569
}
570570
}
571571

572-
internal static void WriteSettings(IList<Http2PeerSetting> settings, Span<byte> destination)
572+
internal static void WriteSettings(List<Http2PeerSetting> settings, Span<byte> destination)
573573
{
574574
foreach (var setting in settings)
575575
{

0 commit comments

Comments
 (0)