tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1684769 - in /tomcat/trunk/java/org/apache/coyote/http2: Http2Parser.java Http2Protocol.java Http2UpgradeHandler.java
Date Wed, 10 Jun 2015 21:31:09 GMT
Author: markt
Date: Wed Jun 10 21:31:08 2015
New Revision: 1684769

URL: http://svn.apache.org/r1684769
Log:
Testing HTTP/2 5.1.2
Make maxConcurrentStream configurable so it can be tested
I have a test for maxConcurrentStreams that works but it appears to be triggering some flow
control bugs I need to iron out. Meanwhile, here are the fixes for the maxConcurrentStreams
bugs it did find.
Ensure headers payload is swallowed if the stream is rejected due to maxConcurrentStreams
Only decrement active stream count when a stream goes inactive

Modified:
    tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java
    tomcat/trunk/java/org/apache/coyote/http2/Http2Protocol.java
    tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java

Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java?rev=1684769&r1=1684768&r2=1684769&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2Parser.java Wed Jun 10 21:31:08 2015
@@ -167,7 +167,12 @@ class Http2Parser {
         if (hpackDecoder == null) {
             hpackDecoder = output.getHpackDecoder();
         }
-        hpackDecoder.setHeaderEmitter(output.headersStart(streamId));
+        try {
+            hpackDecoder.setHeaderEmitter(output.headersStart(streamId));
+        } catch (StreamException se) {
+            swallow(payloadSize);
+            throw se;
+        }
 
         int padLength = 0;
         boolean padding = Flags.hasPadding(flags);

Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2Protocol.java?rev=1684769&r1=1684768&r2=1684769&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2Protocol.java Wed Jun 10 21:31:08 2015
@@ -29,6 +29,8 @@ import org.apache.tomcat.util.net.Socket
 
 public class Http2Protocol implements UpgradeProtocol {
 
+    private static final long DEFAULT_MAX_CONCURRENT_STREAMS = 200;
+
     private static final String HTTP_UPGRADE_NAME = "h2c";
     private static final String ALPN_NAME = "h2";
     private static final byte[] ALPN_IDENTIFIER = ALPN_NAME.getBytes(StandardCharsets.UTF_8);
@@ -37,6 +39,7 @@ public class Http2Protocol implements Up
     private long readTimeout = 10000;
     private long keepAliveTimeout = 30000;
     private long writeTimeout = 10000;
+    private long maxConcurrentStreams = DEFAULT_MAX_CONCURRENT_STREAMS;
 
     @Override
     public String getHttpUpgradeName(boolean isSecure) {
@@ -73,6 +76,7 @@ public class Http2Protocol implements Up
         result.setReadTimeout(getReadTimeout());
         result.setKeepAliveTimeout(getKeepAliveTimeout());
         result.setWriteTimeout(getWriteTimeout());
+        result.setMaxConcurrentStreams(getMaxConcurrentStreams());
 
         return result;
     }
@@ -128,4 +132,14 @@ public class Http2Protocol implements Up
     public void setWriteTimeout(long writeTimeout) {
         this.writeTimeout = writeTimeout;
     }
+
+
+    public long getMaxConcurrentStreams() {
+        return maxConcurrentStreams;
+    }
+
+
+    public void setMaxConcurrentStreams(long maxConcurrentStreams) {
+        this.maxConcurrentStreams = maxConcurrentStreams;
+    }
 }

Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java?rev=1684769&r1=1684768&r2=1684769&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Wed Jun 10 21:31:08
2015
@@ -465,7 +465,10 @@ public class Http2UpgradeHandler extends
             if (stream.getOutputBuffer().isFinished()) {
                 header[4] = FLAG_END_OF_STREAM;
                 stream.sentEndOfStream();
-            }
+                if (!stream.isActive()) {
+                    activeRemoteStreamCount--;
+                }
+             }
             ByteUtil.set31Bits(header, 5, stream.getIdentifier().intValue());
             socketWrapper.write(true, header, 0, header.length);
             socketWrapper.write(true, data.array(), data.arrayOffset() + data.position(),
@@ -723,6 +726,11 @@ public class Http2UpgradeHandler extends
     }
 
 
+    public void setMaxConcurrentStreams(long maxConcurrentStreams) {
+        localSettings.setMaxConcurrentStreams(maxConcurrentStreams);
+    }
+
+
     // ----------------------------------------------- Http2Parser.Input methods
 
     @Override
@@ -776,10 +784,10 @@ public class Http2UpgradeHandler extends
     @Override
     public void receiveEndOfStream(int streamId) throws ConnectionException {
         Stream stream = getStream(streamId, true);
-        if (stream.isActive()) {
+        stream.receivedEndOfStream();
+        if (!stream.isActive()) {
             activeRemoteStreamCount--;
         }
-        stream.receivedEndOfStream();
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message