tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1158331 - in /tomcat/trunk/java/org/apache/coyote/http11: AbstractHttp11Processor.java Http11AprProcessor.java Http11NioProcessor.java Http11Processor.java
Date Tue, 16 Aug 2011 15:45:47 GMT
Author: markt
Date: Tue Aug 16 15:45:46 2011
New Revision: 1158331

URL: http://svn.apache.org/viewvc?rev=1158331&view=rev
Log:
Align keep-alive disable capability across all HTTP processors

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1158331&r1=1158330&r2=1158331&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Tue Aug 16 15:45:46
2011
@@ -778,6 +778,14 @@ public abstract class AbstractHttp11Proc
     
 
     /**
+     * Processors (currently only HTTP BIO) may elect to disable HTTP keep-alive
+     * in some circumstances. This method allows the processor implementation to
+     * determine if keep-alive should be disabled or not. 
+     */
+    protected abstract boolean disableKeepAlive();
+
+
+    /**
      * After reading the request headers, we have to setup the request filters.
      */
     protected void prepareRequest() {

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1158331&r1=1158330&r2=1158331&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Tue Aug 16 15:45:46
2011
@@ -184,6 +184,10 @@ public class Http11AprProcessor extends 
 
         long soTimeout = endpoint.getSoTimeout();
 
+        if (disableKeepAlive()) {
+            socketWrapper.setKeepAliveLeft(0);
+        }
+
         boolean keptAlive = false;
         boolean openSocket = false;
         boolean sendfileInProgress = false;
@@ -353,6 +357,12 @@ public class Http11AprProcessor extends 
 
 
     @Override
+    protected boolean disableKeepAlive() {
+        return false;
+    }
+
+
+    @Override
     protected void resetTimeouts() {
         // NOOP for APR
     }

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1158331&r1=1158330&r2=1158331&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Tue Aug 16 15:45:46
2011
@@ -213,6 +213,10 @@ public class Http11NioProcessor extends 
         
         long soTimeout = endpoint.getSoTimeout();
 
+        if (disableKeepAlive()) {
+            socketWrapper.setKeepAliveLeft(0);
+        }
+
         boolean keptAlive = false;
         boolean openSocket = false;
         boolean readComplete = true;
@@ -399,6 +403,12 @@ public class Http11NioProcessor extends 
 
 
     @Override
+    protected boolean disableKeepAlive() {
+        return false;
+    }
+
+
+    @Override
     public void recycleInternal() {
         socket = null;
         cometClose = false;

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1158331&r1=1158330&r2=1158331&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Tue Aug 16 15:45:46 2011
@@ -148,17 +148,7 @@ public class Http11Processor extends Abs
 
         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 > getDisableKeepAlivePercentage()) {     
+        if (disableKeepAlive()) {
             socketWrapper.setKeepAliveLeft(0);
         }
 
@@ -368,6 +358,26 @@ public class Http11Processor extends Abs
     
     
     @Override
+    protected boolean disableKeepAlive() {
+        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 > getDisableKeepAlivePercentage()) {     
+            return true;
+        }
+        
+        return false;
+    }
+
+
+    @Override
     protected void resetTimeouts() {
         // NOOP for APR
     }



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


Mime
View raw message