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 2015/01/08 14:10:20 UTC

svn commit: r1650274 - /tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java

Author: markt
Date: Thu Jan  8 13:10:20 2015
New Revision: 1650274

URL: http://svn.apache.org/r1650274
Log:
Refactoring with an eye to NIO2.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java?rev=1650274&r1=1650273&r2=1650274&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java Thu Jan  8 13:10:20 2015
@@ -292,7 +292,7 @@ public abstract class SocketWrapperBase<
      */
     public void write(boolean block, byte[] b, int off, int len) throws IOException {
         // Always flush any data remaining in the buffers
-        boolean dataLeft = flush(block);
+        boolean dataLeft = flush(block, true);
 
         if (len == 0 || b == null) {
             return;
@@ -308,7 +308,7 @@ public abstract class SocketWrapperBase<
             if (written == 0) {
                 dataLeft = true;
             } else {
-                dataLeft = flush(block);
+                dataLeft = flush(block, true);
             }
         }
 
@@ -322,7 +322,6 @@ public abstract class SocketWrapperBase<
     }
 
 
-
     /**
      * Writes as much data as possible from any that remains in the buffers.
      *
@@ -336,6 +335,28 @@ public abstract class SocketWrapperBase<
      * @throws IOException If an IO error occurs during the write
      */
     public boolean flush(boolean block) throws IOException {
+        return flush(block, false);
+    }
+
+
+    /**
+     * Writes as much data as possible from any that remains in the buffers.
+     * This method exists for those implementations (e.g. NIO2) that need
+     * slightly different behaviour depending on if flush() was called directly
+     * or by another method in this class or a sub-class.
+     *
+     * @param block    <code>true<code> if a blocking write should be used,
+     *                     otherwise a non-blocking write will be used
+     * @param internal <code>true<code> if flush() was called by another method
+     *                     in class or sub-class
+     *
+     * @return <code>true</code> if data remains to be flushed after this method
+     *         completes, otherwise <code>false</code>. In blocking mode
+     *         therefore, the return value should always be <code>false</code>
+     *
+     * @throws IOException If an IO error occurs during the write
+     */
+    protected boolean flush(boolean block, boolean internal) throws IOException {
 
         // Prevent timeout for async
         access();



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