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 46a6aedb6530d..4d84e54748e3a 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 @@ -1771,23 +1771,18 @@ private bool 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 false; - } - - windowUpdateSize = _pendingWindowUpdate; - _pendingWindowUpdate = 0; + if (NetEventSource.Log.IsEnabled()) Trace($"{nameof(_pendingWindowUpdate)} {_pendingWindowUpdate} < {ConnectionWindowThreshold}."); + return false; } + int windowUpdateSize = _pendingWindowUpdate; + _pendingWindowUpdate = 0; + LogExceptions(SendWindowUpdateAsync(0, windowUpdateSize)); return true; }