This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new cda8f02  Fix possible connection leak with async
cda8f02 is described below

commit cda8f02e7d2a24eb5eb28a2746c88bad9d4aa015
Author: remm <r...@apache.org>
AuthorDate: Mon Apr 15 18:59:59 2019 +0200

    Fix possible connection leak with async
    
    It is necessary to go back to the handler for connection cleanup at the
    moment.
---
 java/org/apache/coyote/http2/Http2AsyncParser.java         | 14 ++++++--------
 java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java |  2 +-
 webapps/docs/changelog.xml                                 |  3 +++
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java 
b/java/org/apache/coyote/http2/Http2AsyncParser.java
index d8f2767..448f3ce 100644
--- a/java/org/apache/coyote/http2/Http2AsyncParser.java
+++ b/java/org/apache/coyote/http2/Http2AsyncParser.java
@@ -31,16 +31,14 @@ import 
org.apache.tomcat.util.net.SocketWrapperBase.CompletionState;
 class Http2AsyncParser extends Http2Parser {
 
     private final SocketWrapperBase<?> socketWrapper;
-    private final Http2AsyncUpgradeHandler upgradeHandler;
     private Throwable error = null;
     private final ByteBuffer header;
     private final ByteBuffer framePaylod;
 
-    Http2AsyncParser(String connectionId, Input input, Output output, 
SocketWrapperBase<?> socketWrapper, Http2AsyncUpgradeHandler upgradeHandler) {
+    Http2AsyncParser(String connectionId, Input input, Output output, 
SocketWrapperBase<?> socketWrapper) {
         super(connectionId, input, output);
         this.socketWrapper = socketWrapper;
         socketWrapper.getSocketBufferHandler().expand(input.getMaxFrameSize());
-        this.upgradeHandler = upgradeHandler;
         header = ByteBuffer.allocate(9);
         framePaylod = ByteBuffer.allocate(input.getMaxFrameSize());
     }
@@ -228,7 +226,7 @@ class Http2AsyncParser extends Http2Parser {
             if (state == CompletionState.DONE) {
                 // The call was not completed inline, so must start reading 
new frames
                 // or process the stream exception
-                upgradeHandler.upgradeDispatch(SocketEvent.OPEN_READ);
+                socketWrapper.processSocket(SocketEvent.OPEN_READ, false);
             }
         }
 
@@ -236,11 +234,11 @@ class Http2AsyncParser extends Http2Parser {
         public void failed(Throwable e, Void attachment) {
             // Always a fatal IO error
             error = e;
+            if (log.isDebugEnabled()) {
+                log.debug(sm.getString("http2Parser.error", connectionId, 
Integer.valueOf(streamId), frameType), e);
+            }
             if (state == null || state == CompletionState.DONE) {
-                if (log.isDebugEnabled()) {
-                    log.debug(sm.getString("http2Parser.error", connectionId, 
Integer.valueOf(streamId), frameType), e);
-                }
-                upgradeHandler.upgradeDispatch(SocketEvent.ERROR);
+                socketWrapper.processSocket(SocketEvent.ERROR, true);
             }
         }
 
diff --git a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java 
b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
index f4559a3..de80eb1 100644
--- a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
@@ -69,7 +69,7 @@ public class Http2AsyncUpgradeHandler extends 
Http2UpgradeHandler {
 
     @Override
     protected Http2Parser getParser(String connectionId) {
-        return new Http2AsyncParser(connectionId, this, this, socketWrapper, 
this);
+        return new Http2AsyncParser(connectionId, this, this, socketWrapper);
     }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index bff8bea..ed16730 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -58,6 +58,9 @@
         The <code>useAsyncIO</code> boolean attribute on the Connector element
         value now defaults to <code>true</code>. (remm)
       </fix>
+      <fix>
+        Possible HTTP/2 connection leak issue when using async. (remm)
+      </fix>
     </changelog>
   </subsection>
 </section>


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

Reply via email to