tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r451157 - in /tomcat/tc6.0.x/trunk/java/org/apache: catalina/connector/ coyote/ajp/ coyote/http11/ tomcat/util/net/
Date Fri, 29 Sep 2006 08:23:37 GMT
Author: mturk
Date: Fri Sep 29 01:23:37 2006
New Revision: 451157

URL: http://svn.apache.org/viewvc?view=rev&rev=451157
Log:
Introduce keepAliveTimeout to be able to separate
the Keep-Alive and Socket timeout.
The patch enables to have infinite socket timeouts
while still having correct keep alive.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Constants.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/mbeans-descriptors.xml
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Constants.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Protocol.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Constants.java?view=diff&rev=451157&r1=451156&r2=451157
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Constants.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Constants.java Fri Sep 29 01:23:37
2006
@@ -34,6 +34,7 @@
     public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
     public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000;
     public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0;
+    public static final int DEFAULT_KEEPALIVE_TIMEOUT = 15000;
 
     public static final int PROCESSOR_IDLE = 0;
     public static final int PROCESSOR_ACTIVE = 1;

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/mbeans-descriptors.xml?view=diff&rev=451157&r1=451156&r2=451157
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/mbeans-descriptors.xml (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/mbeans-descriptors.xml Fri Sep
29 01:23:37 2006
@@ -93,6 +93,10 @@
           description="Maximum number of Keep-Alive requests to honor per connection"
                  type="int"/>
 
+    <attribute   name="keepAliveTimeout"
+          description="The number of seconds Tomcat will wait for a subsequent request before
closing the connection"
+                 type="int"/>
+
     <attribute   name="maxPostSize"
           description="Maximum size in bytes of a POST which will be handled by the servlet
API provided features"
                  type="int"/>

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java?view=diff&rev=451157&r1=451156&r2=451157
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java Fri Sep 29 01:23:37
2006
@@ -417,6 +417,15 @@
         setAttribute("soTimeout", "" + i);
     }
 
+    public int getKeepAliveTimeout() {
+        return ep.getKeepAliveTimeout();
+    }
+
+
+    public void setKeepAliveTimeout( int i ) {
+        ep.setKeepAliveTimeout(i);
+        setAttribute("keepAliveTimeout", "" + i);
+    }
     
     public void setRequiredSecret(String requiredSecret) {
         this.requiredSecret = requiredSecret;

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java?view=diff&rev=451157&r1=451156&r2=451157
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java Fri Sep 29 01:23:37 2006
@@ -38,6 +38,7 @@
     public static final int DEFAULT_CONNECTION_LINGER = -1;
     public static final int DEFAULT_CONNECTION_TIMEOUT = -1;
     public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000;
+    public static final int DEFAULT_KEEPALIVE_TIMEOUT = 15000;    
     public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0;
     public static final boolean DEFAULT_TCP_NO_DELAY = true;
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Constants.java?view=diff&rev=451157&r1=451156&r2=451157
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Constants.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Constants.java Fri Sep 29 01:23:37
2006
@@ -39,6 +39,7 @@
     public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
     public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000;
     public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0;
+    public static final int DEFAULT_KEEPALIVE_TIMEOUT = 15000;
     public static final boolean DEFAULT_TCP_NO_DELAY = true;
     
     

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?view=diff&rev=451157&r1=451156&r2=451157
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Fri Sep 29
01:23:37 2006
@@ -208,6 +208,11 @@
      */
     protected int maxKeepAliveRequests = -1;
 
+    /**
+     * The number of seconds Tomcat will wait for a subsequent request
+     * before closing the connection.
+     */
+    protected int keepAliveTimeout = 15000;
 
     /**
      * SSL enabled ?
@@ -643,6 +648,20 @@
         return maxKeepAliveRequests;
     }
 
+    /**
+     * Set the Keep-Alive timeout.
+     */
+    public void setKeepAliveTimeout(int timeout) {
+        keepAliveTimeout = timeout;
+    }
+
+
+    /**
+     * Return the number Keep-Alive timeout.
+     */
+    public int getKeepAliveTimeout() {
+        return keepAliveTimeout;
+    }
 
     /**
      * Set the maximum size of a POST which will be buffered in SSL mode.

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?view=diff&rev=451157&r1=451156&r2=451157
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Fri Sep 29 01:23:37
2006
@@ -201,6 +201,7 @@
     private int socketBuffer = 9000;
     private Adapter adapter;
     private Http11ConnectionHandler cHandler;
+    private int keepAliveTimeout = 15000; // 15 seconds as in Apache HTTPD server
 
     /**
      * Compression value.
@@ -461,6 +462,14 @@
         maxKeepAliveRequests = mkar;
         setAttribute("maxKeepAliveRequests", "" + mkar);
     }
+
+    /**
+     * The number of seconds Tomcat will wait for a subsequent request
+     * before closing the connection. The default is the same as for
+     * Apache HTTP Server (15 000 milliseconds).
+     */
+    public int getKeepAliveTimeout() { return keepAliveTimeout; }
+    public void setKeepAliveTimeout(int timeout) { keepAliveTimeout = timeout; }
 
     /**
      * Return the Keep-Alive policy for the connection.

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java?view=diff&rev=451157&r1=451156&r2=451157
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java Fri Sep 29 01:23:37
2006
@@ -185,6 +185,12 @@
      */
     protected int maxKeepAliveRequests = -1;
 
+    /**
+     * The number of seconds Tomcat will wait for a subsequent request
+     * before closing the connection.
+     */
+    protected int keepAliveTimeout = 15000;
+
 
     /**
      * SSL information.
@@ -620,6 +626,21 @@
         return maxKeepAliveRequests;
     }
 
+    /**
+     * Set the Keep-Alive timeout.
+     */
+    public void setKeepAliveTimeout(int timeout) {
+        keepAliveTimeout = timeout;
+    }
+
+
+    /**
+     * Return the number Keep-Alive timeout.
+     */
+    public int getKeepAliveTimeout() {
+        return keepAliveTimeout;
+    }
+
 
     /**
      * Set the maximum size of a POST which will be buffered in SSL mode.
@@ -778,8 +799,13 @@
 
             // Parsing the request header
             try {
-                if( !disableUploadTimeout && keptAlive && soTimeout >
0 ) {
-                    socket.setSoTimeout(soTimeout);
+                if (!disableUploadTimeout && keptAlive) {
+                    if (keepAliveTimeout > 0) {
+                        socket.setSoTimeout(keepAliveTimeout);
+                    }
+                    else if (soTimeout > 0) {
+                        socket.setSoTimeout(soTimeout);                        
+                    }
                 }
                 inputBuffer.parseRequestLine();
                 request.setStartTime(System.currentTimeMillis());

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Protocol.java?view=diff&rev=451157&r1=451156&r2=451157
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Protocol.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Protocol.java Fri Sep 29 01:23:37
2006
@@ -70,6 +70,7 @@
     public Http11Protocol() {
         setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
+        setKeepAliveTimeout(Constants.DEFAULT_KEEPALIVE_TIMEOUT);
         //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT);
         setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
     }
@@ -281,6 +282,16 @@
     public int getMaxKeepAliveRequests() { return maxKeepAliveRequests; }
     public void setMaxKeepAliveRequests(int mkar) { maxKeepAliveRequests = mkar; }
 
+    // HTTP
+    /**
+     * The number of seconds Tomcat will wait for a subsequent request
+     * before closing the connection. The default is the same as for
+     * Apache HTTP Server (15 000 milliseconds).
+     */
+    protected int keepAliveTimeout = 15000;
+    public int getKeepAliveTimeout() { return keepAliveTimeout; }
+    public void setKeepAliveTimeout(int timeout) { keepAliveTimeout = timeout; }
+
 
     // HTTP
     /**
@@ -580,6 +591,7 @@
                         new Http11Processor(protocol.maxHttpHeaderSize, protocol.endpoint);
                     processor.setAdapter(protocol.adapter);
                     processor.setMaxKeepAliveRequests(protocol.maxKeepAliveRequests);
+                    processor.setKeepAliveTimeout(protocol.keepAliveTimeout);
                     processor.setTimeout(protocol.timeout);
                     processor.setDisableUploadTimeout(protocol.disableUploadTimeout);
                     processor.setCompression(protocol.compression);

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?view=diff&rev=451157&r1=451156&r2=451157
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Fri Sep 29 01:23:37
2006
@@ -255,6 +255,13 @@
     public int getSoTimeout() { return soTimeout; }
     public void setSoTimeout(int soTimeout) { this.soTimeout = soTimeout; }
 
+    /**
+     * Keep-Alive timeout.
+     */
+    protected int keepAliveTimeout = 15000;
+    public int getKeepAliveTimeout() { return keepAliveTimeout; }
+    public void setKeepAliveTimeout(int timeout) { keepAliveTimeout = timeout; }
+
 
     /**
      * Timeout on first request read before going to the poller, in ms.
@@ -1148,11 +1155,11 @@
         protected void init() {
             pool = Pool.create(serverSockPool);
             int size = pollerSize / pollerThreadCount;
-            int timeout = soTimeout;
+            int timeout = keepAliveTimeout;
             if (comet) {
                 // FIXME: Find an appropriate timeout value, for now, "longer than usual"
                 // semms appropriate
-                timeout = soTimeout * 50;
+                timeout = keepAliveTimeout * 50;
             }
             serverPollset = allocatePoller(size, pool, timeout);
             if (serverPollset == 0 && size > 1024) {
@@ -1566,14 +1573,14 @@
         protected void init() {
             pool = Pool.create(serverSockPool);
             int size = sendfileSize / sendfileThreadCount;
-            sendfilePollset = allocatePoller(size, pool, soTimeout);
+            sendfilePollset = allocatePoller(size, pool, keepAliveTimeout);
             if (sendfilePollset == 0 && size > 1024) {
                 size = 1024;
-                sendfilePollset = allocatePoller(size, pool, soTimeout);
+                sendfilePollset = allocatePoller(size, pool, keepAliveTimeout);
             }
             if (sendfilePollset == 0) {
                 size = 62;
-                sendfilePollset = allocatePoller(size, pool, soTimeout);
+                sendfilePollset = allocatePoller(size, pool, keepAliveTimeout);
             }
             desc = new long[size * 2];
             sendfileData = new HashMap<Long, SendfileData>(size);



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


Mime
View raw message