From: markt Date: Tue, 16 Aug 2011 12:19:49 +0000 (+0000) Subject: Align keep-alive count tracking for HTTP X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7c412087888844c7fcb6b6fd35567dc223cae957;p=tomcat7.0 Align keep-alive count tracking for HTTP git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1158227 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/coyote/http11/Http11AprProcessor.java b/java/org/apache/coyote/http11/Http11AprProcessor.java index 4a94330f4..df0076ded 100644 --- a/java/org/apache/coyote/http11/Http11AprProcessor.java +++ b/java/org/apache/coyote/http11/Http11AprProcessor.java @@ -184,8 +184,6 @@ public class Http11AprProcessor extends AbstractHttp11Processor { long soTimeout = endpoint.getSoTimeout(); - int keepAliveLeft = maxKeepAliveRequests; - boolean keptAlive = false; boolean openSocket = false; boolean sendfileInProgress = false; @@ -253,8 +251,12 @@ public class Http11AprProcessor extends AbstractHttp11Processor { } } - if (maxKeepAliveRequests > 0 && --keepAliveLeft == 0) + if (maxKeepAliveRequests == 1) { + keepAlive = false; + } else if (maxKeepAliveRequests > 0 && + socketWrapper.decrementKeepAlive() <= 0) { keepAlive = false; + } // Process the request in the adapter if (!error) { diff --git a/java/org/apache/coyote/http11/Http11NioProcessor.java b/java/org/apache/coyote/http11/Http11NioProcessor.java index 78f91e60e..c0dd5762d 100644 --- a/java/org/apache/coyote/http11/Http11NioProcessor.java +++ b/java/org/apache/coyote/http11/Http11NioProcessor.java @@ -299,10 +299,12 @@ public class Http11NioProcessor extends AbstractHttp11Processor { } } - if (maxKeepAliveRequests == 1 ) + if (maxKeepAliveRequests == 1) { keepAlive = false; - if (maxKeepAliveRequests > 0 && socketWrapper.decrementKeepAlive() <= 0) + } else if (maxKeepAliveRequests > 0 && + socketWrapper.decrementKeepAlive() <= 0) { keepAlive = false; + } // Process the request in the adapter if (!error) { diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index 653778866..48af529c0 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -148,10 +148,6 @@ public class Http11Processor extends AbstractHttp11Processor { int soTimeout = endpoint.getSoTimeout(); - if (maxKeepAliveRequests > 0) { - socketWrapper.decrementKeepAlive(); - } - int threadRatio = -1; // These may return zero or negative values // Only calculate a thread ratio when both are >0 to ensure we get a @@ -269,7 +265,10 @@ public class Http11Processor extends AbstractHttp11Processor { } } - if (socketWrapper.getKeepAliveLeft() == 0) { + if (maxKeepAliveRequests == 1) { + keepAlive = false; + } else if (maxKeepAliveRequests > 0 && + socketWrapper.decrementKeepAlive() <= 0) { keepAlive = false; } @@ -351,10 +350,6 @@ public class Http11Processor extends AbstractHttp11Processor { if (isAsync() || error || inputBuffer.lastValid == 0) { break; } - - if (maxKeepAliveRequests > 0) { - socketWrapper.decrementKeepAlive(); - } } rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);