- The poller now has good performance, so remove firstReadTimeout (the algorithm...
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 28 Mar 2007 14:01:53 +0000 (14:01 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 28 Mar 2007 14:01:53 +0000 (14:01 +0000)
  svn if needed).

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@523331 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AjpAprProcessor.java
java/org/apache/coyote/ajp/AjpAprProtocol.java
java/org/apache/coyote/http11/Http11AprProcessor.java
java/org/apache/coyote/http11/Http11AprProtocol.java
java/org/apache/coyote/http11/InternalAprInputBuffer.java
java/org/apache/tomcat/util/net/AprEndpoint.java

index a9659ee..786b329 100644 (file)
@@ -90,13 +90,6 @@ public class AjpAprProcessor implements ActionHook {
         responseHeaderMessage = new AjpMessage(packetSize);
         bodyMessage = new AjpMessage(packetSize);
         
-        readTimeout = endpoint.getFirstReadTimeout() * 1000;
-        if (readTimeout == 0) {
-            readTimeout = 100 * 1000;
-        } else if (readTimeout < 0) {
-            readTimeout = -1;
-        }
-
         // Allocate input and output buffers
         inputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
         inputBuffer.limit(0);
@@ -189,13 +182,6 @@ public class AjpAprProcessor implements ActionHook {
 
 
     /**
-     * The socket timeout used when reading the first block of the request
-     * header.
-     */
-    protected long readTimeout;
-
-
-    /**
      * Temp message bytes used for processing.
      */
     protected MessageBytes tmpMB = MessageBytes.newInstance();
@@ -371,11 +357,6 @@ public class AjpAprProcessor implements ActionHook {
         // Error flag
         error = false;
 
-        int limit = 0;
-        if (endpoint.getFirstReadTimeout() > 0) {
-            limit = endpoint.getMaxThreads() / 2;
-        }
-
         boolean openSocket = true;
         boolean keptAlive = false;
 
@@ -384,8 +365,7 @@ public class AjpAprProcessor implements ActionHook {
             // Parsing the request header
             try {
                 // Get first message of the request
-                if (!readMessage(requestHeaderMessage, true,
-                        keptAlive && (endpoint.getCurrentThreadsBusy() >= limit))) {
+                if (!readMessage(requestHeaderMessage, true, keptAlive)) {
                     // This means that no data is available right now
                     // (long keepalive), so that the processor should be recycled
                     // and the method should return true
@@ -1061,15 +1041,9 @@ public class AjpAprProcessor implements ActionHook {
         }
         int nRead;
         while (inputBuffer.remaining() < n) {
-            if (readTimeout > 0) {
-                nRead = Socket.recvbbt
-                    (socket, inputBuffer.limit(),
-                        inputBuffer.capacity() - inputBuffer.limit(), readTimeout);
-            } else {
-                nRead = Socket.recvbb
-                    (socket, inputBuffer.limit(),
-                        inputBuffer.capacity() - inputBuffer.limit());
-            }
+            nRead = Socket.recvbb
+                (socket, inputBuffer.limit(),
+                    inputBuffer.capacity() - inputBuffer.limit());
             if (nRead > 0) {
                 inputBuffer.limit(inputBuffer.limit() + nRead);
             } else {
index df04065..ae8e2b5 100644 (file)
@@ -364,17 +364,6 @@ public class AjpAprProtocol
     }
 
 
-    public int getFirstReadTimeout() {
-        return ep.getFirstReadTimeout();
-    }
-
-
-    public void setFirstReadTimeout(int i) {
-        ep.setFirstReadTimeout(i);
-        setAttribute("firstReadTimeout", "" + i);
-    }
-
-
     public int getPollTime() {
         return ep.getPollTime();
     }
index 124a72c..265068e 100644 (file)
@@ -87,14 +87,7 @@ public class Http11AprProcessor implements ActionHook {
         this.endpoint = endpoint;
         
         request = new Request();
-        int readTimeout = endpoint.getFirstReadTimeout();
-        if (readTimeout == 0) {
-            readTimeout = 100;
-        } else if (readTimeout < 0) {
-            readTimeout = -1;
-        }
-        inputBuffer = new InternalAprInputBuffer(request, headerBufferSize,
-                readTimeout);
+        inputBuffer = new InternalAprInputBuffer(request, headerBufferSize);
         request.setInputBuffer(inputBuffer);
 
         response = new Response();
@@ -800,11 +793,6 @@ public class Http11AprProcessor implements ActionHook {
         int keepAliveLeft = maxKeepAliveRequests;
         long soTimeout = endpoint.getSoTimeout();
         
-        int limit = 0;
-        if (endpoint.getFirstReadTimeout() > 0 || endpoint.getFirstReadTimeout() < -1) {
-            limit = endpoint.getMaxThreads() / 2;
-        }
-
         boolean keptAlive = false;
         boolean openSocket = false;
 
@@ -815,8 +803,7 @@ public class Http11AprProcessor implements ActionHook {
                 if( !disableUploadTimeout && keptAlive && soTimeout > 0 ) {
                     Socket.timeoutSet(socket, soTimeout * 1000);
                 }
-                if (!inputBuffer.parseRequestLine
-                        (keptAlive && (endpoint.getCurrentThreadsBusy() >= limit))) {
+                if (!inputBuffer.parseRequestLine(keptAlive)) {
                     // This means that no data is available right now
                     // (long keepalive), so that the processor should be recycled
                     // and the method should return true
index 1f12d15..ecec00d 100644 (file)
@@ -264,15 +264,6 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration
         setAttribute("port", "" + port);
     }
 
-    public int getFirstReadTimeout() {
-        return ep.getFirstReadTimeout();
-    }
-
-    public void setFirstReadTimeout( int i ) {
-        ep.setFirstReadTimeout(i);
-        setAttribute("firstReadTimeout", "" + i);
-    }
-
     public int getPollTime() {
         return ep.getPollTime();
     }
index bb62a2b..7366eea 100644 (file)
@@ -51,8 +51,7 @@ public class InternalAprInputBuffer implements InputBuffer {
     /**
      * Alternate constructor.
      */
-    public InternalAprInputBuffer(Request request, int headerBufferSize, 
-                                  long readTimeout) {
+    public InternalAprInputBuffer(Request request, int headerBufferSize) {
 
         this.request = request;
         headers = request.getMimeHeaders();
@@ -73,12 +72,6 @@ public class InternalAprInputBuffer implements InputBuffer {
         parsingHeader = true;
         swallowInput = true;
         
-        if (readTimeout < 0) {
-            this.readTimeout = -1;
-        } else {
-            this.readTimeout = readTimeout * 1000;
-        }
-
     }
 
 
@@ -181,13 +174,6 @@ public class InternalAprInputBuffer implements InputBuffer {
     protected int lastActiveFilter;
 
 
-    /**
-     * The socket timeout used when reading the first block of the request
-     * header.
-     */
-    protected long readTimeout;
-    
-    
     // ------------------------------------------------------------- Properties
 
 
@@ -381,26 +367,8 @@ public class InternalAprInputBuffer implements InputBuffer {
                 if (useAvailableData) {
                     return false;
                 }
-                if (readTimeout == -1) {
-                    if (!fill())
-                        throw new EOFException(sm.getString("iib.eof.error"));
-                } else {
-                    // Do a simple read with a short timeout
-                    bbuf.clear();
-                    int nRead = Socket.recvbbt
-                    (socket, 0, buf.length - lastValid, readTimeout);
-                    if (nRead > 0) {
-                        bbuf.limit(nRead);
-                        bbuf.get(buf, pos, nRead);
-                        lastValid = pos + nRead;
-                    } else {
-                        if ((-nRead) == Status.ETIMEDOUT || (-nRead) == Status.TIMEUP) {
-                            return false;
-                        } else {
-                            throw new IOException(sm.getString("iib.failedread"));
-                        }
-                    }
-                }
+                if (!fill())
+                    throw new EOFException(sm.getString("iib.eof.error"));
             }
 
             chr = buf[pos++];
@@ -416,26 +384,8 @@ public class InternalAprInputBuffer implements InputBuffer {
             if (useAvailableData) {
                 return false;
             }
-            if (readTimeout == -1) {
-                if (!fill())
-                    throw new EOFException(sm.getString("iib.eof.error"));
-            } else {
-                // Do a simple read with a short timeout
-                bbuf.clear();
-                int nRead = Socket.recvbbt
-                    (socket, 0, buf.length - lastValid, readTimeout);
-                if (nRead > 0) {
-                    bbuf.limit(nRead);
-                    bbuf.get(buf, pos, nRead);
-                    lastValid = pos + nRead;
-                } else {
-                    if ((-nRead) == Status.ETIMEDOUT || (-nRead) == Status.TIMEUP) {
-                        return false;
-                    } else {
-                        throw new IOException(sm.getString("iib.failedread"));
-                    }
-                }
-            }
+            if (!fill())
+                throw new EOFException(sm.getString("iib.eof.error"));
         }
 
         //
index 16a174d..59ee888 100644 (file)
@@ -272,14 +272,6 @@ public class AprEndpoint {
 
 
     /**
-     * Timeout on first request read before going to the poller, in ms.
-     */
-    protected int firstReadTimeout = -1;
-    public int getFirstReadTimeout() { return firstReadTimeout; }
-    public void setFirstReadTimeout(int firstReadTimeout) { this.firstReadTimeout = firstReadTimeout; }
-
-
-    /**
      * Poll interval, in microseconds. The smaller the value, the more CPU the poller
      * will use, but the more responsive to activity it will be.
      */