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

commit 0aa1a709fa8ada985ecf17d80648014a4e083102
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Aug 2 10:37:46 2024 +0100

    Limit the size of the recycled request/response pools to maxConnections
---
 java/org/apache/coyote/http2/Http2Protocol.java                | 2 ++
 java/org/apache/tomcat/util/collections/SynchronizedStack.java | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/coyote/http2/Http2Protocol.java 
b/java/org/apache/coyote/http2/Http2Protocol.java
index dc9e38eeb3..325ee9bf10 100644
--- a/java/org/apache/coyote/http2/Http2Protocol.java
+++ b/java/org/apache/coyote/http2/Http2Protocol.java
@@ -379,6 +379,8 @@ public class Http2Protocol implements UpgradeProtocol {
     @Override
     public void setHttp11Protocol(AbstractHttp11Protocol<?> http11Protocol) {
         this.http11Protocol = http11Protocol;
+        recycledRequests.setLimit(http11Protocol.getMaxConnections());
+        recycledResponses.setLimit(http11Protocol.getMaxConnections());
 
         try {
             ObjectName oname = 
this.http11Protocol.getONameForUpgrade(getUpgradeProtocolName());
diff --git a/java/org/apache/tomcat/util/collections/SynchronizedStack.java 
b/java/org/apache/tomcat/util/collections/SynchronizedStack.java
index 526c44cef5..992eb5890f 100644
--- a/java/org/apache/tomcat/util/collections/SynchronizedStack.java
+++ b/java/org/apache/tomcat/util/collections/SynchronizedStack.java
@@ -31,7 +31,7 @@ public class SynchronizedStack<T> {
     private static final int DEFAULT_LIMIT = -1;
 
     private int size;
-    private final int limit;
+    private int limit;
 
     /*
      * Points to the next available object in the stack
@@ -89,6 +89,10 @@ public class SynchronizedStack<T> {
         index = -1;
     }
 
+    public synchronized void setLimit(int limit) {
+        this.limit = limit;
+    }
+
     private void expand() {
         int newSize = size * 2;
         if (limit != -1 && newSize > limit) {


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

Reply via email to