- For consistency, add keepAliveTimeout to this protocol handler.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 29 Nov 2006 16:19:23 +0000 (16:19 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 29 Nov 2006 16:19:23 +0000 (16:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@480612 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AjpProcessor.java
java/org/apache/coyote/ajp/AjpProtocol.java

index 2161f2e..3848170 100644 (file)
@@ -327,6 +327,16 @@ public class AjpProcessor implements ActionHook {
     public void setRequiredSecret(String requiredSecret) { this.requiredSecret = requiredSecret; }
 
 
+    /**
+     * The number of milliseconds 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 = -1;
+    public int getKeepAliveTimeout() { return keepAliveTimeout; }
+    public void setKeepAliveTimeout(int timeout) { keepAliveTimeout = timeout; }
+
+
     // --------------------------------------------------------- Public Methods
 
 
@@ -354,6 +364,10 @@ public class AjpProcessor implements ActionHook {
         this.socket = socket;
         input = socket.getInputStream();
         output = socket.getOutputStream();
+        int soTimeout = -1;
+        if (keepAliveTimeout > 0) {
+            soTimeout = socket.getSoTimeout();
+        }
 
         // Error flag
         error = false;
@@ -362,12 +376,20 @@ public class AjpProcessor implements ActionHook {
 
             // Parsing the request header
             try {
+                // Set keep alive timeout if enabled
+                if (keepAliveTimeout > 0) {
+                    socket.setSoTimeout(keepAliveTimeout);
+                }
                 // Get first message of the request
                 if (!readMessage(requestHeaderMessage)) {
                     // This means a connection timeout
                     rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
                     break;
                 }
+                // Set back timeout if keep alive timeout is enabled
+                if (keepAliveTimeout > 0) {
+                    socket.setSoTimeout(soTimeout);
+                }
                 // Check message type, process right away and break if
                 // not regular request processing
                 int type = requestHeaderMessage.getByte();
index 03a5bb8..babee93 100644 (file)
@@ -389,6 +389,16 @@ public class AjpProtocol
     }
 
     
+    /**
+     * 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 = -1;
+    public int getKeepAliveTimeout() { return keepAliveTimeout; }
+    public void setKeepAliveTimeout(int timeout) { keepAliveTimeout = timeout; }
+
+
     // --------------------------------------  AjpConnectionHandler Inner Class
 
 
@@ -411,6 +421,7 @@ public class AjpProtocol
                     processor.setAdapter(proto.adapter);
                     processor.setTomcatAuthentication(proto.tomcatAuthentication);
                     processor.setRequiredSecret(proto.requiredSecret);
+                    processor.setKeepAliveTimeout(proto.keepAliveTimeout);
                     localProcessor.set(processor);
                     if (proto.getDomain() != null) {
                         synchronized (this) {