You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/07/23 16:27:14 UTC

svn commit: r1506059 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/coyote/ajp/AjpNioProcessor.java java/org/apache/coyote/http11/InternalNioOutputBuffer.java java/org/apache/tomcat/util/net/NioEndpoint.java webapps/docs/changelog.xml

Author: markt
Date: Tue Jul 23 14:27:13 2013
New Revision: 1506059

URL: http://svn.apache.org/r1506059
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55267
Separate read and write timeout for NIO and ensure that the write timeout is always the connection timeout configured in the connector. This prevents long Comet timeouts (which are intended for read operations) being used for writes which - particularly in error conditions - can cause long delays.
Since only NIO supports comet timeouts this change is only required in NIO.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1506053

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java?rev=1506059&r1=1506058&r2=1506059&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java Tue Jul 23 14:27:13 2013
@@ -284,7 +284,7 @@ public class AjpNioProcessor extends Abs
         
         NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false);
         if ( att == null ) throw new IOException("Key must be cancelled");
-        long writeTimeout = att.getTimeout();
+        long writeTimeout = att.getWriteTimeout();
         Selector selector = null;
         try {
             selector = pool.get();

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java?rev=1506059&r1=1506058&r2=1506059&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java Tue Jul 23 14:27:13 2013
@@ -152,7 +152,7 @@ public class InternalNioOutputBuffer ext
         int written = 0;
         NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false);
         if ( att == null ) throw new IOException("Key must be cancelled");
-        long writeTimeout = att.getTimeout();
+        long writeTimeout = att.getWriteTimeout();
         Selector selector = null;
         try {
             selector = pool.get();

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1506059&r1=1506058&r2=1506059&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Tue Jul 23 14:27:13 2013
@@ -1499,6 +1499,7 @@ public class NioEndpoint extends Abstrac
             lastAccess = System.currentTimeMillis();
             comet = false;
             timeout = soTimeout;
+            setWriteTimeout(soTimeout);
             error = false;
             lastRegistered = 0;
             sendfileData = null;
@@ -1593,13 +1594,18 @@ public class NioEndpoint extends Abstrac
         public void setSendfileData(SendfileData sf) { this.sendfileData = sf;}
         public SendfileData getSendfileData() { return this.sendfileData;}
 
+        public void setWriteTimeout(long writeTimeout) {
+            this.writeTimeout = writeTimeout;
+        }
+        public long getWriteTimeout() {return this.writeTimeout;}
+
         protected boolean comet = false;
         protected int cometOps = SelectionKey.OP_READ;
         protected boolean cometNotify = false;
         protected CountDownLatch readLatch = null;
         protected CountDownLatch writeLatch = null;
         protected SendfileData sendfileData = null;
-
+        private long writeTimeout = -1;
     }
 
     // ------------------------------------------------ Application Buffer Handler

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1506059&r1=1506058&r2=1506059&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Jul 23 14:27:13 2013
@@ -94,6 +94,12 @@
         Expose the current connection count for each protocol handler via JMX.
         (markt)
       </add>
+      <fix>
+        <bug>55267</bug>: If an application configures a timeout for a Comet
+        connection ensure it is only used for read and not write operations.
+        This prevents a long timeout delaying the closing of the socket
+        associated with a Comet connection after an error occurs. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">



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