hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject httpcomponents-core git commit: Made HTTP/2 data window update precede sending of the DATA frame to the opposite endpoint. In some extreme circumstances the opposite endpoint can send back a WINDOW_UPDATE frame in-between of these two operation causing t
Date Fri, 23 Jun 2017 18:57:12 GMT
Repository: httpcomponents-core
Updated Branches:
  refs/heads/master 79018db83 -> 8f1b4f6d1


Made HTTP/2 data window update precede sending of the DATA frame to the opposite endpoint.
In some extreme circumstances the opposite endpoint can send back a WINDOW_UPDATE frame in-between
of these two operation causing the data window value to exceed its maximum valid value


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/8f1b4f6d
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/8f1b4f6d
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/8f1b4f6d

Branch: refs/heads/master
Commit: 8f1b4f6d16b67059e6ab98ddc1ff545f03ebc4b0
Parents: 79018db
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Fri Jun 23 20:53:32 2017 +0200
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Fri Jun 23 20:55:15 2017 +0200

----------------------------------------------------------------------
 .../nio/AbstractHttp2StreamMultiplexer.java     | 28 +++++++++++---------
 1 file changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8f1b4f6d/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
index af138a8..a685617 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
@@ -307,6 +307,20 @@ abstract class AbstractHttp2StreamMultiplexer implements Identifiable,
HttpConne
         }
     }
 
+    private void streamDataFrame(
+            final int streamId,
+            final AtomicInteger streamOutputWindow,
+            final ByteBuffer payload,
+            final int chunk) throws IOException {
+        final RawFrame dataFrame = frameFactory.createData(streamId, payload, false);
+        if (streamListener != null) {
+            streamListener.onFrameOutput(this, streamId, dataFrame);
+        }
+        updateOutputWindow(0, connOutputWindow, -chunk);
+        updateOutputWindow(streamId, streamOutputWindow, -chunk);
+        outputBuffer.write(dataFrame, ioSession.channel());
+    }
+
     private int streamData(
             final int streamId, final AtomicInteger streamOutputWindow, final ByteBuffer
payload) throws IOException {
         if (outputBuffer.isEmpty() && outputQueue.isEmpty()) {
@@ -319,28 +333,18 @@ abstract class AbstractHttp2StreamMultiplexer implements Identifiable,
HttpConne
             final int chunk;
             if (payload.remaining() <= maxPayloadSize) {
                 chunk = payload.remaining();
-                final RawFrame dataFrame = frameFactory.createData(streamId, payload, false);
-                if (streamListener != null) {
-                    streamListener.onFrameOutput(this, streamId, dataFrame);
-                }
-                outputBuffer.write(dataFrame, ioSession.channel());
+                streamDataFrame(streamId, streamOutputWindow, payload, chunk);
             } else {
                 chunk = maxPayloadSize;
                 final int originalLimit = payload.limit();
                 try {
                     payload.limit(payload.position() + chunk);
-                    final RawFrame dataFrame = frameFactory.createData(streamId, payload,
false);
-                    if (streamListener != null) {
-                        streamListener.onFrameOutput(this, streamId, dataFrame);
-                    }
-                    outputBuffer.write(dataFrame, ioSession.channel());
+                    streamDataFrame(streamId, streamOutputWindow, payload, chunk);
                 } finally {
                     payload.limit(originalLimit);
                 }
             }
             payload.position(payload.position() + chunk);
-            updateOutputWindow(0, connOutputWindow, -chunk);
-            updateOutputWindow(streamId, streamOutputWindow, -chunk);
             ioSession.setEvent(SelectionKey.OP_WRITE);
             return chunk;
         } else {


Mime
View raw message