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 0505fc5  Multiple increment and decrement by 10 to provide more control
0505fc5 is described below

commit 0505fc5aa5b3d4c23d4ce333199260389f1f8a8d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Jun 14 22:21:34 2021 +0100

    Multiple increment and decrement by 10 to provide more control
    
    overheadCountFactor can now be in range 0-20 rather than 0-2.
---
 java/org/apache/coyote/http2/Http2Protocol.java       | 7 ++++---
 java/org/apache/coyote/http2/Http2UpgradeHandler.java | 6 +++---
 webapps/docs/changelog.xml                            | 8 ++++++++
 webapps/docs/config/http2.xml                         | 8 ++++----
 4 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2Protocol.java 
b/java/org/apache/coyote/http2/Http2Protocol.java
index e3028f8..e96a945 100644
--- a/java/org/apache/coyote/http2/Http2Protocol.java
+++ b/java/org/apache/coyote/http2/Http2Protocol.java
@@ -55,10 +55,11 @@ public class Http2Protocol implements UpgradeProtocol {
     // a single connection
     static final int DEFAULT_MAX_CONCURRENT_STREAM_EXECUTION = 20;
 
-    static final int DEFAULT_OVERHEAD_COUNT_FACTOR = 1;
+    static final int DEFAULT_OVERHEAD_COUNT_FACTOR = 10;
     // Not currently configurable. This makes the practical limit for
-    // overheadCountFactor to be 2.
-    static final int DEFAULT_OVERHEAD_REDUCTION_FACTOR = -2;
+    // overheadCountFactor to be ~20. The exact limit will vary with traffic
+    // patterns.
+    static final int DEFAULT_OVERHEAD_REDUCTION_FACTOR = -20;
     static final int DEFAULT_OVERHEAD_CONTINUATION_THRESHOLD = 1024;
     static final int DEFAULT_OVERHEAD_DATA_THRESHOLD = 1024;
     static final int DEFAULT_OVERHEAD_WINDOW_UPDATE_THRESHOLD = 1024;
diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java 
b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 2f9f0da..045d95e 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -1404,7 +1404,7 @@ class Http2UpgradeHandler extends AbstractStream 
implements InternalHttpUpgradeH
         // Http2Protocol.DEFAULT_OVERHEAD_REDUCTION_FACTOR. A simple browser
         // request is likely to have one non-overhead frame (HEADERS) and one
         // overhead frame (REPRIORITISE). With the default settings the 
overhead
-        // count will reduce by 1 for each simple request.
+        // count will reduce by 10 for each simple request.
         // Requests and responses with bodies will create additional
         // non-overhead frames, further reducing the overhead count.
         updateOverheadCount(frameType, 
Http2Protocol.DEFAULT_OVERHEAD_REDUCTION_FACTOR);
@@ -1414,10 +1414,10 @@ class Http2UpgradeHandler extends AbstractStream 
implements InternalHttpUpgradeH
     private void increaseOverheadCount(FrameType frameType) {
         // An overhead frame increases the overhead count by
         // overheadCountFactor. By default, this means an overhead frame
-        // increases the overhead count by 1. A simple browser request is
+        // increases the overhead count by 10. A simple browser request is
         // likely to have one non-overhead frame (HEADERS) and one overhead
         // frame (REPRIORITISE). With the default settings the overhead count
-        // will reduce by 1 for each simple request.
+        // will reduce by 10 for each simple request.
         updateOverheadCount(frameType, getProtocol().getOverheadCountFactor());
     }
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index d013cc5..029c4d8 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -141,6 +141,14 @@
         opens 10 overhead frames in a row will be required to trigger the
         overhead protection. (markt)
       </update>
+      <update>
+        Increase the default <code>overheadCountFactor</code> from
+        <code>1</code> to <code>10</code> and change the reduction in overhead
+        count for a non-overhead frame from <code>-2</code> to 
<code>-20</code>.
+        This allows for a larger range (0-20) to be used for
+        <code>overheadCountFactor</code> providing for finer-grained control.
+        (markt)
+      </update>
     </changelog>
   </subsection>
   <subsection name="Other">
diff --git a/webapps/docs/config/http2.xml b/webapps/docs/config/http2.xml
index 8a4c9c1..fc41e4a 100644
--- a/webapps/docs/config/http2.xml
+++ b/webapps/docs/config/http2.xml
@@ -137,14 +137,14 @@
       <p>The factor to apply when counting overhead frames to determine if a
       connection has too high an overhead and should be closed. The overhead
       count starts at <code>-10 * overheadCountFactor</code>. The count is
-      decreased by 2 for each data frame sent or received and each headers 
frame
+      decreased by 20 for each data frame sent or received and each headers 
frame
       received. The count is increased by the <code>overheadCountFactor</code>
       for each setting received, priority frame received and ping received. If
       the overhead count exceeds zero, the connection is closed. A value of 
less
       than <code>1</code> disables this protection. In normal usage a value of
-      <code>3</code> or more will close the connection before any streams can
-      complete. If not specified, a default value of <code>1</code> will be
-      used.</p>
+      approximately <code>20</code> or higher will close the connection before
+      any streams can complete. If not specified, a default value of
+      <code>10</code> will be used.</p>
     </attribute>
 
     <attribute name="overheadDataThreshold" required="false">

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

Reply via email to