Skip to content

Commit 97c47e2

Browse files
author
ladeak
committed
WindowUpdateLock back to using Lock type and Http2Stream uses Interlocked pattern for DecrementActiveClientStreamCount
1 parent 917aff3 commit 97c47e2

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ internal sealed class Http2FrameWriter
9999
private bool _completed;
100100
private bool _aborted;
101101

102-
private readonly object _windowUpdateLock = new();
102+
private readonly Lock _windowUpdateLock = new();
103103
private long _connectionWindow;
104104
private readonly Queue<Http2OutputProducer> _waitingForMoreConnectionWindow = new();
105105
// This is the stream that consumed the last set of connection window

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -630,14 +630,9 @@ public void DecrementActiveClientStreamCount()
630630
{
631631
// Decrement can be called twice, via calling CompleteAsync and then Abort on the HttpContext.
632632
// Only decrement once total.
633-
lock (_completionLock)
633+
if (Interlocked.CompareExchange(ref _decrementCalled, true, false))
634634
{
635-
if (_decrementCalled)
636-
{
637-
return;
638-
}
639-
640-
_decrementCalled = true;
635+
return;
641636
}
642637

643638
_context.StreamLifetimeHandler.DecrementActiveClientStreamCount();

0 commit comments

Comments
 (0)