From 863b18e34f12085820ad02e86ca0ef7e961bb471 Mon Sep 17 00:00:00 2001
From: Mark Thomas <markt@apache.org>
Date: Wed, 7 Aug 2019 18:59:07 +0100
Subject: [PATCH 1/5] Extend the timeout functionality to internal upgrade
 processors

---
 .../coyote/http11/upgrade/InternalHttpUpgradeHandler.java   | 2 ++
 .../coyote/http11/upgrade/UpgradeProcessorInternal.java     | 6 ++++++
 java/org/apache/coyote/http2/Http2UpgradeHandler.java       | 6 ++++++
 .../tomcat/websocket/server/WsHttpUpgradeHandler.java       | 6 ++++++
 .../coyote/http11/upgrade/TestUpgradeInternalHandler.java   | 5 +++++
 5 files changed, 25 insertions(+)

diff --git a/java/org/apache/coyote/http11/upgrade/InternalHttpUpgradeHandler.java b/java/org/apache/coyote/http11/upgrade/InternalHttpUpgradeHandler.java
index 936784e20c..426b1bdb89 100644
--- a/java/org/apache/coyote/http11/upgrade/InternalHttpUpgradeHandler.java
+++ b/java/org/apache/coyote/http11/upgrade/InternalHttpUpgradeHandler.java
@@ -32,6 +32,8 @@ public interface InternalHttpUpgradeHandler extends HttpUpgradeHandler {
 
     SocketState upgradeDispatch(SocketEvent status);
 
+    void timeoutAsync(long now);
+
     void setSocketWrapper(SocketWrapperBase<?> wrapper);
 
     void setSslSupport(SSLSupport sslSupport);
diff --git a/java/org/apache/coyote/http11/upgrade/UpgradeProcessorInternal.java b/java/org/apache/coyote/http11/upgrade/UpgradeProcessorInternal.java
index 6397a72a53..f0f546072d 100644
--- a/java/org/apache/coyote/http11/upgrade/UpgradeProcessorInternal.java
+++ b/java/org/apache/coyote/http11/upgrade/UpgradeProcessorInternal.java
@@ -73,6 +73,12 @@ public class UpgradeProcessorInternal extends UpgradeProcessorBase {
     }
 
 
+    @Override
+    public void timeoutAsync(long now) {
+        internalHttpUpgradeHandler.timeoutAsync(now);
+    }
+
+
     // --------------------------------------------------- AutoCloseable methods
 
     @Override
diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 6206f5f5f2..da724652aa 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -388,6 +388,12 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
     }
 
 
+    @Override
+    public void timeoutAsync(long now) {
+        // TODO: Implement improved connection timeouts
+    }
+
+
     ConnectionSettingsRemote getRemoteSettings() {
         return remoteSettings;
     }
diff --git a/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java b/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java
index 0cde0e3672..5dd1c5a68c 100644
--- a/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java
+++ b/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java
@@ -189,6 +189,12 @@ public class WsHttpUpgradeHandler implements InternalHttpUpgradeHandler {
     }
 
 
+    @Override
+    public void timeoutAsync(long now) {
+        // NO-OP
+    }
+
+
     @Override
     public void pause() {
         // NO-OP
diff --git a/test/org/apache/coyote/http11/upgrade/TestUpgradeInternalHandler.java b/test/org/apache/coyote/http11/upgrade/TestUpgradeInternalHandler.java
index 367f06f5b3..183a8dac7f 100644
--- a/test/org/apache/coyote/http11/upgrade/TestUpgradeInternalHandler.java
+++ b/test/org/apache/coyote/http11/upgrade/TestUpgradeInternalHandler.java
@@ -256,6 +256,11 @@ public class TestUpgradeInternalHandler extends TomcatBaseTest {
             return SocketState.UPGRADED;
         }
 
+        @Override
+        public void timeoutAsync(long now) {
+            // NO-OP
+        }
+
         @Override
         public void setSocketWrapper(SocketWrapperBase<?> wrapper) {
             this.wrapper = wrapper;
-- 
2.23.0

