Skip to content

Commit 66b83da

Browse files
authored
Merge pull request #51266 from vseanreesermsft/internal-merge-7.0-2023-10-10-1033
Merging internal commits for release/7.0
2 parents 794c22c + 37c8b00 commit 66b83da

File tree

11 files changed

+505
-378
lines changed

11 files changed

+505
-378
lines changed

NuGet.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<clear />
55
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
66
<!-- Begin: Package sources from dotnet-efcore -->
7-
<add key="darc-int-dotnet-efcore-8133d0c" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-efcore-8133d0c8/nuget/v3/index.json" />
7+
<add key="darc-int-dotnet-efcore-c20ecc7" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-efcore-c20ecc79/nuget/v3/index.json" />
88
<!-- End: Package sources from dotnet-efcore -->
99
<!-- Begin: Package sources from dotnet-runtime -->
10-
<add key="darc-int-dotnet-runtime-ecb34f8" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-ecb34f85/nuget/v3/index.json" />
10+
<add key="darc-int-dotnet-runtime-4a824ef" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-4a824ef3/nuget/v3/index.json" />
1111
<!-- End: Package sources from dotnet-runtime -->
1212
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
1313
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
@@ -26,10 +26,10 @@
2626
<clear />
2727
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
2828
<!-- Begin: Package sources from dotnet-efcore -->
29-
<add key="darc-int-dotnet-efcore-8133d0c" value="true" />
29+
<add key="darc-int-dotnet-efcore-c20ecc7" value="true" />
3030
<!-- End: Package sources from dotnet-efcore -->
3131
<!-- Begin: Package sources from dotnet-runtime -->
32-
<add key="darc-int-dotnet-runtime-ecb34f8" value="true" />
32+
<add key="darc-int-dotnet-runtime-4a824ef" value="true" />
3333
<!-- End: Package sources from dotnet-runtime -->
3434
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
3535
</disabledPackageSources>

eng/Baseline.Designer.props

Lines changed: 210 additions & 210 deletions
Large diffs are not rendered by default.

eng/Baseline.xml

Lines changed: 104 additions & 104 deletions
Large diffs are not rendered by default.

eng/Version.Details.xml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,37 @@
99
-->
1010
<Dependencies>
1111
<ProductDependencies>
12-
<Dependency Name="dotnet-ef" Version="7.0.11">
12+
<Dependency Name="dotnet-ef" Version="7.0.12">
1313
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
14-
<Sha>8133d0c827462d8d84e47b70f294fc060a5d7a84</Sha>
14+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
1515
</Dependency>
16-
<Dependency Name="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.11">
16+
<Dependency Name="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.12">
1717
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
18-
<Sha>8133d0c827462d8d84e47b70f294fc060a5d7a84</Sha>
18+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
1919
</Dependency>
20-
<Dependency Name="Microsoft.EntityFrameworkCore.Relational" Version="7.0.11">
20+
<Dependency Name="Microsoft.EntityFrameworkCore.Relational" Version="7.0.12">
2121
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
22-
<Sha>8133d0c827462d8d84e47b70f294fc060a5d7a84</Sha>
22+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
2323
</Dependency>
24-
<Dependency Name="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.11">
24+
<Dependency Name="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.12">
2525
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
26-
<Sha>8133d0c827462d8d84e47b70f294fc060a5d7a84</Sha>
26+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
2727
</Dependency>
28-
<Dependency Name="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.11">
28+
<Dependency Name="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.12">
2929
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
30-
<Sha>8133d0c827462d8d84e47b70f294fc060a5d7a84</Sha>
30+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
3131
</Dependency>
32-
<Dependency Name="Microsoft.EntityFrameworkCore.Tools" Version="7.0.11">
32+
<Dependency Name="Microsoft.EntityFrameworkCore.Tools" Version="7.0.12">
3333
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
34-
<Sha>8133d0c827462d8d84e47b70f294fc060a5d7a84</Sha>
34+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
3535
</Dependency>
36-
<Dependency Name="Microsoft.EntityFrameworkCore" Version="7.0.11">
36+
<Dependency Name="Microsoft.EntityFrameworkCore" Version="7.0.12">
3737
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
38-
<Sha>8133d0c827462d8d84e47b70f294fc060a5d7a84</Sha>
38+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
3939
</Dependency>
40-
<Dependency Name="Microsoft.EntityFrameworkCore.Design" Version="7.0.11">
40+
<Dependency Name="Microsoft.EntityFrameworkCore.Design" Version="7.0.12">
4141
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
42-
<Sha>8133d0c827462d8d84e47b70f294fc060a5d7a84</Sha>
42+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
4343
</Dependency>
4444
<Dependency Name="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0">
4545
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
@@ -177,9 +177,9 @@
177177
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
178178
<Sha>d099f075e45d2aa6007a22b71b45a08758559f80</Sha>
179179
</Dependency>
180-
<Dependency Name="Microsoft.Internal.Runtime.AspNetCore.Transport" Version="7.0.11-servicing.23424.27">
180+
<Dependency Name="Microsoft.Internal.Runtime.AspNetCore.Transport" Version="7.0.12-servicing.23477.20">
181181
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
182-
<Sha>ecb34f85ec92e1b3c814edf7da83337e199e7f66</Sha>
182+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
183183
</Dependency>
184184
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="7.0.0-alpha.1.22505.1">
185185
<Uri>https://github.com/dotnet/source-build-externals</Uri>
@@ -256,39 +256,39 @@
256256
</Dependency>
257257
<Dependency Name="System.Threading.RateLimiting" Version="7.0.1">
258258
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
259-
<Sha>ecb34f85ec92e1b3c814edf7da83337e199e7f66</Sha>
259+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
260260
</Dependency>
261261
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="7.0.0">
262262
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
263263
<Sha>d099f075e45d2aa6007a22b71b45a08758559f80</Sha>
264264
</Dependency>
265-
<Dependency Name="Microsoft.NETCore.App.Ref" Version="7.0.11">
265+
<Dependency Name="Microsoft.NETCore.App.Ref" Version="7.0.12">
266266
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
267-
<Sha>ecb34f85ec92e1b3c814edf7da83337e199e7f66</Sha>
267+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
268268
</Dependency>
269-
<Dependency Name="Microsoft.NET.Runtime.MonoAOTCompiler.Task" Version="7.0.11">
269+
<Dependency Name="Microsoft.NET.Runtime.MonoAOTCompiler.Task" Version="7.0.12">
270270
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
271-
<Sha>ecb34f85ec92e1b3c814edf7da83337e199e7f66</Sha>
271+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
272272
</Dependency>
273-
<Dependency Name="Microsoft.NET.Runtime.WebAssembly.Sdk" Version="7.0.11">
273+
<Dependency Name="Microsoft.NET.Runtime.WebAssembly.Sdk" Version="7.0.12">
274274
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
275-
<Sha>ecb34f85ec92e1b3c814edf7da83337e199e7f66</Sha>
275+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
276276
</Dependency>
277277
<!--
278278
Win-x64 is used here because we have picked an arbitrary runtime identifier to flow the version of the latest NETCore.App runtime.
279279
All Runtime.$rid packages should have the same version.
280280
-->
281-
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="7.0.11">
281+
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="7.0.12">
282282
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
283-
<Sha>ecb34f85ec92e1b3c814edf7da83337e199e7f66</Sha>
283+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
284284
</Dependency>
285-
<Dependency Name="Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.browser-wasm" Version="7.0.11">
285+
<Dependency Name="Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.browser-wasm" Version="7.0.12">
286286
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
287-
<Sha>ecb34f85ec92e1b3c814edf7da83337e199e7f66</Sha>
287+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
288288
</Dependency>
289-
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="7.0.11-servicing.23424.27">
289+
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="7.0.12-servicing.23477.20">
290290
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
291-
<Sha>ecb34f85ec92e1b3c814edf7da83337e199e7f66</Sha>
291+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
292292
</Dependency>
293293
<Dependency Name="Microsoft.Web.Xdt" Version="7.0.0-preview.22423.2">
294294
<Uri>https://github.com/dotnet/xdt</Uri>

eng/Versions.props

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@
6363
<PropertyGroup Label="Automated">
6464
<!-- Packages from dotnet/runtime -->
6565
<MicrosoftExtensionsDependencyModelVersion>7.0.0</MicrosoftExtensionsDependencyModelVersion>
66-
<MicrosoftNETCoreAppRefVersion>7.0.11</MicrosoftNETCoreAppRefVersion>
67-
<MicrosoftNETCoreAppRuntimewinx64Version>7.0.11</MicrosoftNETCoreAppRuntimewinx64Version>
68-
<MicrosoftNETRuntimeMonoAOTCompilerTaskVersion>7.0.11</MicrosoftNETRuntimeMonoAOTCompilerTaskVersion>
69-
<MicrosoftNETRuntimeWebAssemblySdkVersion>7.0.11</MicrosoftNETRuntimeWebAssemblySdkVersion>
70-
<MicrosoftNETCoreAppRuntimeAOTwinx64CrossbrowserwasmVersion>7.0.11</MicrosoftNETCoreAppRuntimeAOTwinx64CrossbrowserwasmVersion>
71-
<MicrosoftNETCoreBrowserDebugHostTransportVersion>7.0.11-servicing.23424.27</MicrosoftNETCoreBrowserDebugHostTransportVersion>
66+
<MicrosoftNETCoreAppRefVersion>7.0.12</MicrosoftNETCoreAppRefVersion>
67+
<MicrosoftNETCoreAppRuntimewinx64Version>7.0.12</MicrosoftNETCoreAppRuntimewinx64Version>
68+
<MicrosoftNETRuntimeMonoAOTCompilerTaskVersion>7.0.12</MicrosoftNETRuntimeMonoAOTCompilerTaskVersion>
69+
<MicrosoftNETRuntimeWebAssemblySdkVersion>7.0.12</MicrosoftNETRuntimeWebAssemblySdkVersion>
70+
<MicrosoftNETCoreAppRuntimeAOTwinx64CrossbrowserwasmVersion>7.0.12</MicrosoftNETCoreAppRuntimeAOTwinx64CrossbrowserwasmVersion>
71+
<MicrosoftNETCoreBrowserDebugHostTransportVersion>7.0.12-servicing.23477.20</MicrosoftNETCoreBrowserDebugHostTransportVersion>
7272
<MicrosoftExtensionsCachingAbstractionsVersion>7.0.0</MicrosoftExtensionsCachingAbstractionsVersion>
7373
<MicrosoftExtensionsCachingMemoryVersion>7.0.0</MicrosoftExtensionsCachingMemoryVersion>
7474
<MicrosoftExtensionsConfigurationAbstractionsVersion>7.0.0</MicrosoftExtensionsConfigurationAbstractionsVersion>
@@ -103,7 +103,7 @@
103103
<MicrosoftExtensionsOptionsDataAnnotationsVersion>7.0.0</MicrosoftExtensionsOptionsDataAnnotationsVersion>
104104
<MicrosoftExtensionsOptionsVersion>7.0.1</MicrosoftExtensionsOptionsVersion>
105105
<MicrosoftExtensionsPrimitivesVersion>7.0.0</MicrosoftExtensionsPrimitivesVersion>
106-
<MicrosoftInternalRuntimeAspNetCoreTransportVersion>7.0.11-servicing.23424.27</MicrosoftInternalRuntimeAspNetCoreTransportVersion>
106+
<MicrosoftInternalRuntimeAspNetCoreTransportVersion>7.0.12-servicing.23477.20</MicrosoftInternalRuntimeAspNetCoreTransportVersion>
107107
<SystemConfigurationConfigurationManagerVersion>7.0.0</SystemConfigurationConfigurationManagerVersion>
108108
<SystemDiagnosticsDiagnosticSourceVersion>7.0.2</SystemDiagnosticsDiagnosticSourceVersion>
109109
<SystemDiagnosticsEventLogVersion>7.0.0</SystemDiagnosticsEventLogVersion>
@@ -125,14 +125,14 @@
125125
<!-- Only listed explicitly to workaround https://github.com/dotnet/cli/issues/10528 -->
126126
<MicrosoftNETCorePlatformsVersion>7.0.4</MicrosoftNETCorePlatformsVersion>
127127
<!-- Packages from dotnet/efcore -->
128-
<dotnetefVersion>7.0.11</dotnetefVersion>
129-
<MicrosoftEntityFrameworkCoreInMemoryVersion>7.0.11</MicrosoftEntityFrameworkCoreInMemoryVersion>
130-
<MicrosoftEntityFrameworkCoreRelationalVersion>7.0.11</MicrosoftEntityFrameworkCoreRelationalVersion>
131-
<MicrosoftEntityFrameworkCoreSqliteVersion>7.0.11</MicrosoftEntityFrameworkCoreSqliteVersion>
132-
<MicrosoftEntityFrameworkCoreSqlServerVersion>7.0.11</MicrosoftEntityFrameworkCoreSqlServerVersion>
133-
<MicrosoftEntityFrameworkCoreToolsVersion>7.0.11</MicrosoftEntityFrameworkCoreToolsVersion>
134-
<MicrosoftEntityFrameworkCoreVersion>7.0.11</MicrosoftEntityFrameworkCoreVersion>
135-
<MicrosoftEntityFrameworkCoreDesignVersion>7.0.11</MicrosoftEntityFrameworkCoreDesignVersion>
128+
<dotnetefVersion>7.0.12</dotnetefVersion>
129+
<MicrosoftEntityFrameworkCoreInMemoryVersion>7.0.12</MicrosoftEntityFrameworkCoreInMemoryVersion>
130+
<MicrosoftEntityFrameworkCoreRelationalVersion>7.0.12</MicrosoftEntityFrameworkCoreRelationalVersion>
131+
<MicrosoftEntityFrameworkCoreSqliteVersion>7.0.12</MicrosoftEntityFrameworkCoreSqliteVersion>
132+
<MicrosoftEntityFrameworkCoreSqlServerVersion>7.0.12</MicrosoftEntityFrameworkCoreSqlServerVersion>
133+
<MicrosoftEntityFrameworkCoreToolsVersion>7.0.12</MicrosoftEntityFrameworkCoreToolsVersion>
134+
<MicrosoftEntityFrameworkCoreVersion>7.0.12</MicrosoftEntityFrameworkCoreVersion>
135+
<MicrosoftEntityFrameworkCoreDesignVersion>7.0.12</MicrosoftEntityFrameworkCoreDesignVersion>
136136
<!-- Packages from dotnet/arcade -->
137137
<MicrosoftDotNetBuildTasksInstallersVersion>7.0.0-beta.23408.3</MicrosoftDotNetBuildTasksInstallersVersion>
138138
<MicrosoftDotNetBuildTasksTemplatingVersion>7.0.0-beta.23408.3</MicrosoftDotNetBuildTasksTemplatingVersion>

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
3-
"version": "7.0.111"
3+
"version": "7.0.112"
44
},
55
"tools": {
6-
"dotnet": "7.0.111",
6+
"dotnet": "7.0.112",
77
"runtimes": {
88
"dotnet/x86": [
99
"$(MicrosoftNETCoreBrowserDebugHostTransportVersion)"

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

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,31 @@ internal sealed partial class Http2Connection : IHttp2StreamLifetimeHandler, IHt
4646
private const int MaxStreamPoolSize = 100;
4747
private const long StreamPoolExpiryTicks = TimeSpan.TicksPerSecond * 5;
4848

49+
private const string MaximumEnhanceYourCalmCountProperty = "Microsoft.AspNetCore.Server.Kestrel.Http2.MaxEnhanceYourCalmCount";
50+
51+
private static readonly int _enhanceYourCalmMaximumCount = GetMaximumEnhanceYourCalmCount();
52+
53+
private static int GetMaximumEnhanceYourCalmCount()
54+
{
55+
var data = AppContext.GetData(MaximumEnhanceYourCalmCountProperty);
56+
if (data is int count)
57+
{
58+
return count;
59+
}
60+
if (data is string countStr && int.TryParse(countStr, out var parsed))
61+
{
62+
return parsed;
63+
}
64+
65+
return 20; // Empirically derived
66+
}
67+
68+
// Accumulate _enhanceYourCalmCount over the course of EnhanceYourCalmTickWindowCount ticks.
69+
// This should make bursts less likely to trigger disconnects.
70+
private const int EnhanceYourCalmTickWindowCount = 5;
71+
72+
private static bool IsEnhanceYourCalmEnabled => _enhanceYourCalmMaximumCount > 0;
73+
4974
private readonly HttpConnectionContext _context;
5075
private readonly Http2FrameWriter _frameWriter;
5176
private readonly Pipe _input;
@@ -74,6 +99,9 @@ internal sealed partial class Http2Connection : IHttp2StreamLifetimeHandler, IHt
7499
private int _clientActiveStreamCount;
75100
private int _serverActiveStreamCount;
76101

102+
private int _enhanceYourCalmCount;
103+
private int _tickCount;
104+
77105
// The following are the only fields that can be modified outside of the ProcessRequestsAsync loop.
78106
private readonly ConcurrentQueue<Http2Stream> _completedStreams = new ConcurrentQueue<Http2Stream>();
79107
private readonly StreamCloseAwaitable _streamCompletionAwaitable = new StreamCloseAwaitable();
@@ -361,13 +389,20 @@ public async Task ProcessRequestsAsync<TContext>(IHttpApplication<TContext> appl
361389
stream.Abort(new IOException(CoreStrings.Http2StreamAborted, connectionError));
362390
}
363391

364-
// Use the server _serverActiveStreamCount to drain all requests on the server side.
365-
// Can't use _clientActiveStreamCount now as we now decrement that count earlier/
366-
// Can't use _streams.Count as we wait for RST/END_STREAM before removing the stream from the dictionary
367-
while (_serverActiveStreamCount > 0)
392+
// For some reason, this loop doesn't terminate when we're trying to abort.
393+
// Since we're making a narrow fix for a patch, we'll bypass it in such scenarios.
394+
// TODO: This is probably a bug - something in here should probably detect aborted
395+
// connections and short-circuit.
396+
if (!IsEnhanceYourCalmEnabled || error is not Http2ConnectionErrorException)
368397
{
369-
await _streamCompletionAwaitable;
370-
UpdateCompletedStreams();
398+
// Use the server _serverActiveStreamCount to drain all requests on the server side.
399+
// Can't use _clientActiveStreamCount now as we now decrement that count earlier/
400+
// Can't use _streams.Count as we wait for RST/END_STREAM before removing the stream from the dictionary
401+
while (_serverActiveStreamCount > 0)
402+
{
403+
await _streamCompletionAwaitable;
404+
UpdateCompletedStreams();
405+
}
371406
}
372407

373408
while (StreamPool.TryPop(out var pooledStream))
@@ -1170,6 +1205,20 @@ private void StartStream()
11701205
// Server is getting hit hard with connection resets.
11711206
// Tell client to calm down.
11721207
// TODO consider making when to send ENHANCE_YOUR_CALM configurable?
1208+
1209+
if (IsEnhanceYourCalmEnabled && Interlocked.Increment(ref _enhanceYourCalmCount) > EnhanceYourCalmTickWindowCount * _enhanceYourCalmMaximumCount)
1210+
{
1211+
Log.Http2TooManyEnhanceYourCalms(_context.ConnectionId, _enhanceYourCalmMaximumCount);
1212+
1213+
// Now that we've logged a useful message, we can put vague text in the exception
1214+
// messages in case they somehow make it back to the client (not expected)
1215+
1216+
// This will close the socket - we want to do that right away
1217+
Abort(new ConnectionAbortedException(CoreStrings.Http2ConnectionFaulted));
1218+
// Throwing an exception as well will help us clean up on our end more quickly by (e.g.) skipping processing of already-buffered input
1219+
throw new Http2ConnectionErrorException(CoreStrings.Http2ConnectionFaulted, Http2ErrorCode.ENHANCE_YOUR_CALM);
1220+
}
1221+
11731222
throw new Http2StreamErrorException(_currentHeadersStream.StreamId, CoreStrings.Http2TellClientToCalmDown, Http2ErrorCode.ENHANCE_YOUR_CALM);
11741223
}
11751224
}
@@ -1241,6 +1290,12 @@ private void AbortStream(int streamId, IOException error)
12411290
void IRequestProcessor.Tick(DateTimeOffset now)
12421291
{
12431292
Input.CancelPendingRead();
1293+
// We count EYCs over a window of a given length to avoid flagging short-lived bursts.
1294+
// At the end of each window, reset the count.
1295+
if (IsEnhanceYourCalmEnabled && ++_tickCount % EnhanceYourCalmTickWindowCount == 0)
1296+
{
1297+
Interlocked.Exchange(ref _enhanceYourCalmCount, 0);
1298+
}
12441299
}
12451300

12461301
void IHttp2StreamLifetimeHandler.OnStreamCompleted(Http2Stream stream)

0 commit comments

Comments
 (0)