Author: markt
Date: Wed Aug 30 20:51:48 2017
New Revision: 1806733

URL: http://svn.apache.org/viewvc?rev=1806733&view=rev
Log:
Fix random SocketTimeoutExceptions when reading the request InputStream.
The problem was some components treated a timeout of zero as a non-blocking 
read and some as an infinite timeout. This patch causes 0 to be treated as an 
infinite timeout.
This closes #9
Based on a patch by Peter Major. (markt)

Modified:
    
tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
    tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java
    tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml

Modified: 
tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java?rev=1806733&r1=1806732&r2=1806733&view=diff
==============================================================================
--- 
tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java 
(original)
+++ 
tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java 
Wed Aug 30 20:51:48 2017
@@ -131,8 +131,7 @@ public class InternalNioInputBuffer exte
                     throw new IOException("Key must be cancelled.");
                 }
                 nRead = pool.read(readBuffer,
-                        socket, selector,
-                        socket.getIOChannel().socket().getSoTimeout());
+                        socket, selector, att.getTimeout());
             } catch ( EOFException eof ) {
                 nRead = -1;
             } finally {

Modified: 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java?rev=1806733&r1=1806732&r2=1806733&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java 
(original)
+++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java Wed 
Aug 30 20:51:48 2017
@@ -98,7 +98,13 @@ public class SocketWrapper<E> {
         }
     }
     public void access(long access) { lastAccess = access; }
-    public void setTimeout(long timeout) {this.timeout = timeout;}
+    public void setTimeout(long timeout) {
+        if (timeout > 0) {
+            this.timeout = timeout;
+        } else {
+            this.timeout = -1;
+        }
+    }
     public long getTimeout() {return this.timeout;}
     // error is used by NIO2 - will move to Nio2SocketWraper in Tomcat 9
     public boolean getError() { return error; }

Modified: tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml?rev=1806733&r1=1806732&r2=1806733&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml Wed Aug 30 20:51:48 2017
@@ -85,6 +85,10 @@
         In this case the client certificate without the chain will be presented
         to the application. (markt)
       </fix>
+      <fix>
+        Fix random <code>SocketTimeoutException</code>s when reading the 
request
+        <code>InputStream</code>. Based on a patch by Peter Major. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Tribes">



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

Reply via email to