Pull up flush()
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Aug 2011 11:40:05 +0000 (11:40 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Aug 2011 11:40:05 +0000 (11:40 +0000)
APR (like BIO and NIO) now writes each AJP packet to the socket as soon as it is ready

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1160639 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AbstractAjpProcessor.java
java/org/apache/coyote/ajp/AjpAprProcessor.java
java/org/apache/coyote/ajp/AjpNioProcessor.java
java/org/apache/coyote/ajp/AjpProcessor.java

index 50c9bc0..0acc719 100644 (file)
@@ -537,7 +537,6 @@ public abstract class AbstractAjpProcessor<S> extends AbstractProcessor<S> {
 
     // Methods called by action()
     protected abstract void actionInternal(ActionCode actionCode, Object param);
-    protected abstract void flush(boolean tbd) throws IOException;
     protected abstract void finish() throws IOException;
 
     // Methods called by prepareResponse()
@@ -557,6 +556,17 @@ public abstract class AbstractAjpProcessor<S> extends AbstractProcessor<S> {
 
 
     /**
+     * Callback to write data from the buffer.
+     */
+    protected void flush(boolean explicit) throws IOException {
+        if (explicit && !finished) {
+            // Send the flush message
+            output(flushMessageArray, 0, flushMessageArray.length);
+        }
+    }
+
+    
+    /**
      * After reading the request headers, we have to setup the request filters.
      */
     protected void prepareRequest() {
index b2a25f6..70c6fb8 100644 (file)
@@ -269,6 +269,15 @@ public class AjpAprProcessor extends AbstractAjpProcessor<Long> {
     protected void output(byte[] src, int offset, int length)
             throws IOException {
         outputBuffer.put(src, offset, length);
+        
+        long socketRef = socket.getSocket().longValue();
+        
+        if (outputBuffer.position() > 0) {
+            if ((socketRef != 0) && Socket.sendbb(socketRef, 0, outputBuffer.position()) < 0) {
+                throw new IOException(sm.getString("ajpprocessor.failedsend"));
+            }
+            outputBuffer.clear();
+        }
     }
 
 
@@ -497,28 +506,4 @@ public class AjpAprProcessor extends AbstractAjpProcessor<Long> {
         outputBuffer.clear();
 
     }
-
-
-    /**
-     * Callback to write data from the buffer.
-     */
-    @Override
-    protected void flush(boolean explicit) throws IOException {
-        
-        long socketRef = socket.getSocket().longValue();
-        
-        if (outputBuffer.position() > 0) {
-            if ((socketRef != 0) && Socket.sendbb(socketRef, 0, outputBuffer.position()) < 0) {
-                throw new IOException(sm.getString("ajpprocessor.failedsend"));
-            }
-            outputBuffer.clear();
-        }
-        // Send explicit flush message
-        if (explicit && !finished &&  (socketRef != 0)) {
-            if (Socket.send(socketRef, flushMessageArray, 0,
-                    flushMessageArray.length) < 0) {
-                throw new IOException(sm.getString("ajpprocessor.failedflush"));
-            }
-        }
-    }
 }
index 3bd5980..48f1d9b 100644 (file)
@@ -486,14 +486,4 @@ public class AjpNioProcessor extends AbstractAjpProcessor<NioChannel> {
     }
 
 
-    /**
-     * Callback to write data from the buffer.
-     */
-    @Override
-    protected void flush(boolean explicit) throws IOException {
-        if (explicit && !finished) {
-            // Send the flush message
-            output(flushMessageArray, 0, flushMessageArray.length);
-        }
-    }
 }
index 6f524b7..d47b1eb 100644 (file)
@@ -433,16 +433,4 @@ public class AjpProcessor extends AbstractAjpProcessor<Socket> {
             return true;
         }
     }
-
-
-    /**
-     * Callback to write data from the buffer.
-     */
-    @Override
-    protected void flush(boolean explicit) throws IOException {
-        if (explicit && !finished) {
-            // Send the flush message
-            output.write(flushMessageArray);
-        }
-    }
 }