PR feedback
authorGeoff Kizer <geoffrek>
Wed, 20 Feb 2019 03:54:30 +0000 (19:54 -0800)
committerGeoff Kizer <geoffrek>
Wed, 20 Feb 2019 03:54:30 +0000 (19:54 -0800)
Commit migrated from https://github.com/dotnet/corefx/commit/8b4d2f58cd89efbe0d0b2a487d5ce96353c83150

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs

index 8e51085..7481441 100644 (file)
@@ -56,6 +56,13 @@ namespace System.Net.Http
         // 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)
index c4a747c..cc846d8 100644 (file)
@@ -37,6 +37,8 @@ namespace System.Net.Http
             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)
@@ -312,7 +314,8 @@ namespace System.Net.Http
                 (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);
                 }