From 46d3ba320ed51b7dfe7053634dadd3dfc35e4b20 Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 28 Oct 2009 15:30:49 +0000 Subject: [PATCH] Ensure thread ratio calc is valid git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@830589 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/coyote/http11/Http11Processor.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index a69304e67..48137ddda 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -171,8 +171,16 @@ public class Http11Processor extends AbstractHttp11Processor implements ActionHo int soTimeout = endpoint.getSoTimeout(); - int threadRatio = (endpoint.getCurrentThreadsBusy() * 100) - / endpoint.getMaxThreads(); + 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; } -- 2.11.0