[jbossweb-commits] JBossWeb SVN: r2276 - in branches/7.4.x/src/main/java/org/apache/tomcat/websocket: server and 1 other directory.

jbossweb-commits at lists.jboss.org jbossweb-commits at lists.jboss.org
Thu Oct 10 12:12:38 EDT 2013


Author: remy.maucherat at jboss.com
Date: 2013-10-10 12:12:38 -0400 (Thu, 10 Oct 2013)
New Revision: 2276

Modified:
   branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
   branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java
   branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java
   branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
Log:
Port patch and improve my flush trick (don't know if it is correct yet).

Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java	2013-10-09 06:59:38 UTC (rev 2275)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java	2013-10-10 16:12:38 UTC (rev 2276)
@@ -274,7 +274,11 @@
             MessagePart mpNext = messagePartQueue.poll();
             if (mpNext == null) {
                 messagePartInProgress = false;
-            } else {
+            } else if (!closed){
+                // Session may have been closed unexpectedly in the middle of
+                // sending a fragmented message closing the endpoint. If this
+                // happens, clearly there is no point trying to send the rest of
+                // the message.
                 writeMessagePart(mpNext);
             }
         }
@@ -561,6 +565,7 @@
 
 
     protected abstract void doWrite(SendHandler handler, ByteBuffer... data);
+    protected abstract void doFlush() throws IOException;
     protected abstract boolean isMasked();
     protected abstract void doClose();
 

Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java	2013-10-09 06:59:38 UTC (rev 2275)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java	2013-10-10 16:12:38 UTC (rev 2276)
@@ -16,6 +16,7 @@
  */
 package org.apache.tomcat.websocket;
 
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.TimeUnit;
 
@@ -37,6 +38,11 @@
 
 
     @Override
+    protected void doFlush() throws IOException {
+    }
+
+
+    @Override
     protected void doWrite(SendHandler handler, ByteBuffer... data) {
         long timeout = getSendTimeout();
         if (timeout < 1) {

Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java	2013-10-09 06:59:38 UTC (rev 2275)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java	2013-10-10 16:12:38 UTC (rev 2276)
@@ -440,7 +440,7 @@
      * Force an autoblocking flush.
      */
     public void forceFlush() throws IOException {
-        wsRemoteEndpoint.flushBatch();
+        wsRemoteEndpoint.doFlush();
     }
 
     private void fireEndpointOnClose(CloseReason closeReason) {

Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java	2013-10-09 06:59:38 UTC (rev 2275)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java	2013-10-10 16:12:38 UTC (rev 2276)
@@ -65,6 +65,14 @@
     }
 
 
+    @Override
+    protected void doFlush() throws IOException {
+        if (timeoutExpiry != -1) {
+            sos.flush();
+        }
+    }
+
+
     public void onWritePossible() {
         boolean complete = true;
         try {
@@ -81,8 +89,11 @@
                     }
                 }
                 if (complete) {
+                    timeoutExpiry = -1;
                     wsWriteTimeout.unregister(this);
                     clearHandler(null);
+                    // Explicit flush for compatibility with buffered streams
+                    sos.flush();
                     if (close) {
                         close();
                     }



More information about the jbossweb-commits mailing list