Skip to content

Commit

Permalink
Fix h2 connection timeout issue with useAsyncIO=true
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Feb 9, 2023
1 parent 3925849 commit a4ea8cc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions java/org/apache/coyote/AbstractProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,9 @@ public SocketState process(SocketWrapperBase<S> wrapper, SocketEvent status) {
} 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
Expand Down
40 changes: 40 additions & 0 deletions test/org/apache/coyote/http2/TestHttp2ConnectionTimeouts.java
Original file line number Diff line number Diff line change
@@ -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());
}
}
5 changes: 5 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@
<code>WINDOW_UPDATE</code> frame on an HTTP/2 connection where the flow
control window for the overall connection has been exhausted. (markt)
</fix>
<fix>
Fix a regression introduced in 9.0.65 that prevented HTTP/2 connections
from timing out when using a Connector configured with
<code>useAsyncIO=true</code> (the default for NIO and NIO2). (markt)
</fix>
</changelog>
</subsection>
<subsection name="Jasper">
Expand Down

0 comments on commit a4ea8cc

Please sign in to comment.