// We limit it per stream, and the user controls how many streams are created.
// So set the connection window size to a large value.
private const int ConnectionWindowSize = 64 * 1024 * 1024;
+
+ // We hold off on sending WINDOW_UPDATE until we hit thi minimum threshold.
+ // This value is somewhat arbitrary; the intent is to ensure it is much smaller than
+ // the window size itself, or we risk stalling the server because it runs out of window space.
+ // If we want to further reduce the frequency of WINDOW_UPDATEs, it's probably better to
+ // increase the window size (and thus increase the threshold proportionally)
+ // rather than just increase the threshold.
private const int ConnectionWindowThreshold = ConnectionWindowSize / 8;
public Http2Connection(HttpConnectionPool pool, SslStream stream)
private bool _disposed;
private const int StreamWindowSize = DefaultInitialWindowSize;
+
+ // See comment on ConnectionWindowThreshold.
private const int StreamWindowThreshold = StreamWindowSize / 8;
public Http2Stream(HttpRequestMessage request, Http2Connection connection, int streamId, int initialWindowSize)
(waitForData, bytesRead) = TryReadFromBuffer(buffer.Span);
if (waitForData != null)
{
- await waitForData;
+ Debug.Assert(bytesRead == 0);
+ await waitForData.ConfigureAwait(false);
(waitForData, bytesRead) = TryReadFromBuffer(buffer.Span);
Debug.Assert(waitForData == null);
}