From bd4f7e4233fe0c22e60ab7b4c3d866f79491a12c Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 5 May 2011 14:29:04 +0000 Subject: [PATCH] Revert r830965 and restore the automatic disabling of HTTP keep-alive once 75% of the threads are in use. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1099820 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/coyote/http11/Http11Processor.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index 80c3910e5..c44c8249b 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -171,6 +171,20 @@ public class Http11Processor extends AbstractHttp11Processor { int soTimeout = endpoint.getSoTimeout(); + int threadRatio = -1; + // These may return zero or negative values + // Only calculate a thread ratio when both are >0 to ensure we get a + // sensible result + if (endpoint.getCurrentThreadsBusy() >0 && + endpoint.getMaxThreads() >0) { + threadRatio = (endpoint.getCurrentThreadsBusy() * 100) + / endpoint.getMaxThreads(); + } + // Disable keep-alive if we are running low on threads + if (threadRatio > 75) { + keepAliveLeft = 1; + } + try { socket.getSocket().setSoTimeout(soTimeout); } catch (Throwable t) { -- 2.11.0