This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new 65a4677b1b Fix h2 connection timeout issue with useAsyncIO=true 65a4677b1b is described below commit 65a4677b1bb7eb41e92244af3d9dcd0cc15068cf Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Feb 9 17:32:50 2023 +0000 Fix h2 connection timeout issue with useAsyncIO=true --- java/org/apache/coyote/AbstractProtocol.java | 3 ++ .../coyote/http2/TestHttp2ConnectionTimeouts.java | 40 ++++++++++++++++++++++ webapps/docs/changelog.xml | 5 +++ 3 files changed, 48 insertions(+) diff --git a/java/org/apache/coyote/AbstractProtocol.java b/java/org/apache/coyote/AbstractProtocol.java index ccb3dffdb3..673228ab24 100644 --- a/java/org/apache/coyote/AbstractProtocol.java +++ b/java/org/apache/coyote/AbstractProtocol.java @@ -984,6 +984,9 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler, MBeanRegis } else if (state == SocketState.ASYNC_IO) { // Don't add sockets back to the poller. // The handler will initiate all further I/O + if (status != SocketEvent.OPEN_WRITE) { + getProtocol().addWaitingProcessor(processor); + } } else if (state == SocketState.SUSPENDED) { // Don't add sockets back to the poller. // The resumeProcessing() method will add this socket diff --git a/test/org/apache/coyote/http2/TestHttp2ConnectionTimeouts.java b/test/org/apache/coyote/http2/TestHttp2ConnectionTimeouts.java new file mode 100644 index 0000000000..5f1970daaf --- /dev/null +++ b/test/org/apache/coyote/http2/TestHttp2ConnectionTimeouts.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.coyote.http2; + +import org.junit.Assert; +import org.junit.Test; + +public class TestHttp2ConnectionTimeouts extends Http2TestBase { + + @Test + public void testConnectionTimeout() throws Exception { + + // Reduce default timeouts so test completes sooner + enableHttp2(200, false, 5000, 5000, 10000, 5000, 5000); + configureAndStartWebApplication(); + openClientConnection(false); + doHttpUpgrade(); + sendClientPreface(); + validateHttp2InitialResponse(); + + // Wait for timeout - should receive GoAway frame + parser.readFrame(); + + Assert.assertEquals("0-Goaway-[1]-[0]-[null]", output.getTrace()); + } +} diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 670bd464e3..dca43edfc0 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -183,6 +183,11 @@ ensure that the end of stream flag is set on the headers frame and that no data frame is sent. (markt) </fix> + <fix> + Fix a bug that prevented HTTP/2 connections from timing out when using + a Connector configured with <code>useAsyncIO=true</code> (the default). + (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org