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

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 2aa6261276 Apply the initial HTTP/2 connection limits earlier.
2aa6261276 is described below

commit 2aa6261276ebe50b99276953591e3a2be7898bdb
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Jul 1 19:58:55 2025 +0100

    Apply the initial HTTP/2 connection limits earlier.
---
 .../apache/coyote/http2/ConnectionSettingsBase.java   | 19 +++++++++++++++++--
 .../apache/coyote/http2/ConnectionSettingsLocal.java  |  5 ++++-
 java/org/apache/coyote/http2/Http2UpgradeHandler.java |  8 ++++++--
 webapps/docs/changelog.xml                            |  4 ++++
 4 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/coyote/http2/ConnectionSettingsBase.java 
b/java/org/apache/coyote/http2/ConnectionSettingsBase.java
index 749fac5cff..47141ba050 100644
--- a/java/org/apache/coyote/http2/ConnectionSettingsBase.java
+++ b/java/org/apache/coyote/http2/ConnectionSettingsBase.java
@@ -66,6 +66,11 @@ abstract class ConnectionSettingsBase<T extends Throwable> {
 
 
     final void set(Setting setting, long value) throws T {
+        set(setting,  value, false);
+    }
+
+
+    final void set(Setting setting, long value, boolean force) throws T {
         if (log.isTraceEnabled()) {
             log.trace(sm.getString("connectionSettings.debug", connectionId, 
getEndpointName(), setting,
                     Long.toString(value)));
@@ -102,11 +107,21 @@ abstract class ConnectionSettingsBase<T extends 
Throwable> {
                 return;
         }
 
-        set(setting, Long.valueOf(value));
+        set(setting, Long.valueOf(value), force);
     }
 
 
-    synchronized void set(Setting setting, Long value) {
+    /**
+     * Specify a new value for setting with the option to force the change to 
take effect immediately rather than
+     * waiting until an {@code ACK} is received.
+     *
+     * @param setting The setting to update
+     * @param value   The new value for the setting
+     * @param force   {@code false} if an {@code ACK} must be received before 
the setting takes effect or {@code true}
+     *                    if the setting to take effect immediately. Even if 
the setting takes effect immediately, it
+     *                    will still be included in the next {@code SETTINGS} 
frame and an {@code ACK} will be expected.
+     */
+    synchronized void set(Setting setting, Long value, boolean force) {
         current.put(setting, value);
     }
 
diff --git a/java/org/apache/coyote/http2/ConnectionSettingsLocal.java 
b/java/org/apache/coyote/http2/ConnectionSettingsLocal.java
index 372be80223..5ceec8ece1 100644
--- a/java/org/apache/coyote/http2/ConnectionSettingsLocal.java
+++ b/java/org/apache/coyote/http2/ConnectionSettingsLocal.java
@@ -40,12 +40,15 @@ class ConnectionSettingsLocal extends 
ConnectionSettingsBase<IllegalArgumentExce
 
 
     @Override
-    final synchronized void set(Setting setting, Long value) {
+    final synchronized void set(Setting setting, Long value, boolean force) {
         checkSend();
         if (current.get(setting).longValue() == value.longValue()) {
             pending.remove(setting);
         } else {
             pending.put(setting, value);
+            if (force) {
+                current.put(setting, value);
+            }
         }
     }
 
diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java 
b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index dbcdc1b83a..fed5a3baf7 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -164,8 +164,12 @@ class Http2UpgradeHandler extends AbstractStream 
implements InternalHttpUpgradeH
         remoteSettings = new ConnectionSettingsRemote(connectionId);
         localSettings = new ConnectionSettingsLocal(connectionId);
 
-        localSettings.set(Setting.MAX_CONCURRENT_STREAMS, 
protocol.getMaxConcurrentStreams());
-        localSettings.set(Setting.INITIAL_WINDOW_SIZE, 
protocol.getInitialWindowSize());
+        /*
+         * Force set these initial limits. A well-behaved client should ACK 
the settings and adhere to them before it
+         * reaches the limits anyway.
+         */
+        localSettings.set(Setting.MAX_CONCURRENT_STREAMS, 
protocol.getMaxConcurrentStreams(), true);
+        localSettings.set(Setting.INITIAL_WINDOW_SIZE, 
protocol.getInitialWindowSize(), true);
 
         pingManager.initiateDisabled = protocol.getInitiatePingDisabled();
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 1066565486..4985c634f9 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -157,6 +157,10 @@
         application tries to use CLIENT-CERT with either HTTP/2 or a JSSE
         implementation of TLS 1.3. (markt)
       </fix>
+      <fix>
+        When setting the initial HTTP/2 connection limit, apply those limits
+        earlier. (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

Reply via email to