@@ -49,19 +49,19 @@ public InputFlowControl(uint initialWindowSize, uint minWindowSizeIncrement)
4949 {
5050 Debug . Assert ( initialWindowSize >= minWindowSizeIncrement , "minWindowSizeIncrement is greater than the window size." ) ;
5151
52- _flow = new FlowControlState ( initialWindowSize , false ) ;
52+ _flow = new FlowControlState ( initialWindowSize , isAborted : false ) ;
5353 _initialWindowSize = initialWindowSize ;
5454 _minWindowSizeIncrement = ( int ) minWindowSizeIncrement ;
5555 }
5656
5757 public bool IsAvailabilityLow => _flow . Available < _minWindowSizeIncrement ;
5858
59- // Test hook, not participating in mutual exclusion
59+ // Test hook
6060 internal uint Available => _flow . Available ;
6161
6262 public void Reset ( )
6363 {
64- _flow = new FlowControlState ( _initialWindowSize , false ) ;
64+ _flow = new FlowControlState ( _initialWindowSize , isAborted : false ) ;
6565 _pendingUpdateSize = 0 ;
6666 _windowUpdatesDisabled = false ;
6767 }
@@ -103,13 +103,11 @@ public bool TryUpdateWindow(int bytes, out int updateSize)
103103 return false ;
104104 }
105105
106- var maxUpdate = int . MaxValue - currentFlow . Available ;
107- if ( bytes > maxUpdate )
108- {
109- // We only try to update the window back to its initial size after the app consumes data.
110- // It shouldn't be possible for the window size to ever exceed Http2PeerSettings.MaxWindowSize.
111- Debug . Assert ( false , $ "{ nameof ( TryUpdateWindow ) } attempted to grow window past max size.") ;
112- }
106+ var maxUpdate = Http2PeerSettings . MaxWindowSize - currentFlow . Available ;
107+
108+ // We only try to update the window back to its initial size after the app consumes data.
109+ // It shouldn't be possible for the window size to ever exceed Http2PeerSettings.MaxWindowSize.
110+ Debug . Assert ( bytes <= maxUpdate , $ "{ nameof ( TryUpdateWindow ) } attempted to grow window past max size.") ;
113111 computedFlow = new FlowControlState ( currentFlow . Available + ( uint ) bytes , isAborted : false ) ;
114112 } while ( currentFlow . _state != Interlocked . CompareExchange ( ref _flow . _state , computedFlow . _state , currentFlow . _state ) ) ;
115113
0 commit comments