Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46985
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 8 Apr 2009 14:58:20 +0000 (14:58 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 8 Apr 2009 14:58:20 +0000 (14:58 +0000)
There is still some optimisation possible but I think this is a good balance between clarity and oprimisation.

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

java/org/apache/coyote/http11/Http11Processor.java

index 6e04cc7..d629b07 100644 (file)
@@ -734,7 +734,7 @@ public class Http11Processor implements ActionHook {
      * responses
      * @throws IOException error during an I/O operation
      */
-    public void process(Socket socket)
+    public void process(Socket theSocket)
         throws IOException {
         RequestInfo rp = request.getRequestProcessor();
         rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);
@@ -748,7 +748,7 @@ public class Http11Processor implements ActionHook {
         localPort = -1;
 
         // Setting up the I/O
-        this.socket = socket;
+        this.socket = theSocket;
         inputBuffer.setInputStream(socket.getInputStream());
         outputBuffer.setOutputStream(socket.getOutputStream());
 
@@ -757,8 +757,7 @@ public class Http11Processor implements ActionHook {
         keepAlive = true;
 
         int keepAliveLeft = maxKeepAliveRequests;
-        int soTimeout = socket.getSoTimeout();
-        int oldSoTimeout = soTimeout;
+        int soTimeout = endpoint.getSoTimeout();
 
         int threadRatio = (endpoint.getCurrentThreadsBusy() * 100)
                 / endpoint.getMaxThreads();
@@ -766,13 +765,11 @@ public class Http11Processor implements ActionHook {
             keepAliveLeft = 1;
         }
         
-        if (soTimeout != oldSoTimeout) {
-            try {
-                socket.setSoTimeout(soTimeout);
-            } catch (Throwable t) {
-                log.debug(sm.getString("http11processor.socket.timeout"), t);
-                error = true;
-            }
+        try {
+            socket.setSoTimeout(soTimeout);
+        } catch (Throwable t) {
+            log.debug(sm.getString("http11processor.socket.timeout"), t);
+            error = true;
         }
 
         boolean keptAlive = false;
@@ -792,7 +789,9 @@ public class Http11Processor implements ActionHook {
                 inputBuffer.parseRequestLine();
                 request.setStartTime(System.currentTimeMillis());
                 keptAlive = true;
-                if (!disableUploadTimeout) {
+                if (disableUploadTimeout) {
+                    socket.setSoTimeout(soTimeout);
+                } else {
                     socket.setSoTimeout(timeout);
                 }
                 inputBuffer.parseHeaders();