From e86972d9d6367d273459852d9ea25a9b62f66296 Mon Sep 17 00:00:00 2001 From: antonfirsov Date: Fri, 2 Feb 2024 15:29:00 +0100 Subject: [PATCH 1/2] remove synchronization from Http2Connection.ExtendWindow --- .../SocketsHttpHandler/Http2Connection.cs | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs index ba233513cbf0b7..3794b4ba75582a 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs @@ -1776,23 +1776,18 @@ private void ExtendWindow(int amount) { if (NetEventSource.Log.IsEnabled()) Trace($"{nameof(amount)}={amount}"); Debug.Assert(amount > 0); + Debug.Assert(_pendingWindowUpdate < ConnectionWindowThreshold); - int windowUpdateSize; - lock (SyncObject) + _pendingWindowUpdate += amount; + if (_pendingWindowUpdate < ConnectionWindowThreshold) { - Debug.Assert(_pendingWindowUpdate < ConnectionWindowThreshold); - - _pendingWindowUpdate += amount; - if (_pendingWindowUpdate < ConnectionWindowThreshold) - { - if (NetEventSource.Log.IsEnabled()) Trace($"{nameof(_pendingWindowUpdate)} {_pendingWindowUpdate} < {ConnectionWindowThreshold}."); - return; - } - - windowUpdateSize = _pendingWindowUpdate; - _pendingWindowUpdate = 0; + if (NetEventSource.Log.IsEnabled()) Trace($"{nameof(_pendingWindowUpdate)} {_pendingWindowUpdate} < {ConnectionWindowThreshold}."); + return; } + int windowUpdateSize = _pendingWindowUpdate; + _pendingWindowUpdate = 0; + LogExceptions(SendWindowUpdateAsync(0, windowUpdateSize)); } From 0ef3f7d76f22eabf5cf3a97d914ce69a702fa8ba Mon Sep 17 00:00:00 2001 From: antonfirsov Date: Tue, 13 Feb 2024 22:11:04 +0100 Subject: [PATCH 2/2] adjust formatting --- .../src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs index 46304d0d375dd1..4d84e54748e3ab 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs @@ -1777,7 +1777,7 @@ private bool ExtendWindow(int amount) if (_pendingWindowUpdate < ConnectionWindowThreshold) { if (NetEventSource.Log.IsEnabled()) Trace($"{nameof(_pendingWindowUpdate)} {_pendingWindowUpdate} < {ConnectionWindowThreshold}."); - return false; + return false; } int windowUpdateSize = _pendingWindowUpdate;