Author: remm
Date: Wed May  7 16:00:44 2014
New Revision: 1593047

URL: http://svn.apache.org/r1593047
Log:
- Fix possible (very rare) corruption doing keepalive after a Comet request.
- Stop ignoring read pending exceptions.

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java
    tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java
    tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java?rev=1593047&r1=1593046&r2=1593047&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java 
(original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java Wed May 
 7 16:00:44 2014
@@ -132,7 +132,9 @@ public class Http11Nio2Processor extends
             if (keepAlive) {
                 inputBuffer.nextRequest();
                 outputBuffer.nextRequest();
-                return SocketState.OPEN;
+                // Following Comet processing, a read is still pending, so
+                // keep the processor associated
+                return SocketState.LONG;
             } else {
                 return SocketState.CLOSED;
             }

Modified: 
tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java?rev=1593047&r1=1593046&r2=1593047&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java 
(original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java Wed 
May  7 16:00:44 2014
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 import java.nio.channels.CompletionHandler;
-import java.nio.channels.ReadPendingException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
@@ -265,12 +264,8 @@ public class InternalNio2InputBuffer ext
                         flipped = false;
                         readPending = true;
                         Nio2Endpoint.startInline();
-                        try {
-                            socket.getSocket().read(byteBuffer, 
socket.getTimeout(),
+                        socket.getSocket().read(byteBuffer, 
socket.getTimeout(),
                                     TimeUnit.MILLISECONDS, socket, 
completionHandler);
-                        } catch (ReadPendingException e) {
-                            // Ignore ?
-                        }
                         Nio2Endpoint.endInline();
                         // Return the number of bytes that have been placed 
into the buffer
                         if (!readPending) {

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1593047&r1=1593046&r2=1593047&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Wed May  7 
16:00:44 2014
@@ -29,7 +29,6 @@ import java.nio.channels.AsynchronousSoc
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.CompletionHandler;
 import java.nio.channels.FileChannel;
-import java.nio.channels.ReadPendingException;
 import java.nio.file.StandardOpenOption;
 import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
@@ -922,12 +921,8 @@ public class Nio2Endpoint extends Abstra
         }
         ByteBuffer byteBuffer = 
socket.getSocket().getBufHandler().getReadBuffer();
         byteBuffer.clear();
-        try {
-            socket.getSocket().read(byteBuffer, socket.getTimeout(),
-                    TimeUnit.MILLISECONDS, socket, awaitBytes);
-        } catch (ReadPendingException e) {
-            // Ignore
-        }
+        socket.getSocket().read(byteBuffer, socket.getTimeout(),
+               TimeUnit.MILLISECONDS, socket, awaitBytes);
     }
 
     public boolean processSendfile(final Nio2SocketWrapper socket) {

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1593047&r1=1593046&r2=1593047&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed May  7 16:00:44 2014
@@ -182,6 +182,9 @@
         <bug>56416</bug>: Correct documentation for default value of socket
         linger for the AJP and HTTP connectors. (markt)
       </fix>
+      <fix>
+        Fix possible corruption if doing keepalive after a comet request. 
(remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">



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

Reply via email to