tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1487598 - in /tomcat/trunk/java/org/apache/coyote: ActionCode.java Response.java http11/AbstractHttp11Processor.java http11/InternalNioOutputBuffer.java
Date Wed, 29 May 2013 19:10:44 GMT
Author: markt
Date: Wed May 29 19:10:43 2013
New Revision: 1487598

URL: http://svn.apache.org/r1487598
Log:
Simplify. Buffered data left over after a non-blcoking write is written in the processor

Modified:
    tomcat/trunk/java/org/apache/coyote/ActionCode.java
    tomcat/trunk/java/org/apache/coyote/Response.java
    tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
    tomcat/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java

Modified: tomcat/trunk/java/org/apache/coyote/ActionCode.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ActionCode.java?rev=1487598&r1=1487597&r2=1487598&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ActionCode.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ActionCode.java Wed May 29 19:10:43 2013
@@ -213,12 +213,6 @@ public enum ActionCode {
     NB_WRITE_INTEREST,
 
     /**
-     * Flush the lower level buffers and re-register the socket with the poller
-     * if the buffers cannot be completely flushed.
-     */
-    NB_WRITE_FLUSH,
-
-    /**
      * Indicates if the request body has been fully read.
      */
     REQUEST_BODY_FULLY_READ

Modified: tomcat/trunk/java/org/apache/coyote/Response.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/Response.java?rev=1487598&r1=1487597&r2=1487598&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/Response.java (original)
+++ tomcat/trunk/java/org/apache/coyote/Response.java Wed May 29 19:10:43 2013
@@ -595,16 +595,9 @@ public final class Response {
     }
 
     public void onWritePossible() throws IOException {
-        // Flush the lower level buffers
-        // If data left in buffers wait for next onWritePossible. Socket will
-        // have been placed in poller if buffers weren't emptied.
-        AtomicBoolean isDataLeftInBuffers = new AtomicBoolean(true);
-        action(ActionCode.NB_WRITE_FLUSH, isDataLeftInBuffers);
-        if (isDataLeftInBuffers.get()) {
-            return;
-        }
-
-        // No data in lower level buffers. Ready for app to write more data.
+        // Any buffered data left over from a previous non-blocking write is
+        // written in the Processor so if this point is reached the app is able
+        // to write data.
         boolean fire = false;
         synchronized (fireListenerLock) {
             if (fireListener) {

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1487598&r1=1487597&r2=1487598&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Wed May 29 19:10:43
2013
@@ -821,14 +821,6 @@ public abstract class AbstractHttp11Proc
                 // TODO
                 throw new IllegalStateException();
             }
-        } else if (actionCode == ActionCode.NB_WRITE_FLUSH) {
-            AtomicBoolean isDataLeftInBuffers = (AtomicBoolean)param;
-            try {
-                isDataLeftInBuffers.set(getOutputBuffer().flushBuffer(false));
-            } catch (IOException e) {
-                // TODO
-                throw new IllegalStateException();
-            }
         } else if (actionCode == ActionCode.NB_READ_INTEREST) {
             registerForEvent(true, false);
         } else if (actionCode == ActionCode.UPGRADE) {

Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java?rev=1487598&r1=1487597&r2=1487598&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java Wed May 29 19:10:43
2013
@@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.coyote.OutputBuffer;
 import org.apache.coyote.Response;
@@ -82,6 +83,8 @@ public class InternalNioOutputBuffer ext
      */
     protected volatile boolean flipped = false;
 
+    private final AtomicLong bytesWritten = new AtomicLong(0);
+
     // --------------------------------------------------------- Public Methods
 
     /**
@@ -96,6 +99,7 @@ public class InternalNioOutputBuffer ext
             socket = null;
         }
         flipped = false;
+        bytesWritten.set(0);
     }
 
 
@@ -157,6 +161,10 @@ public class InternalNioOutputBuffer ext
             // Still have data to write
             registerWriteInterest();
         }
+        if (written == 0) {
+            (new Exception("written == 0")).printStackTrace();
+        }
+        System.out.println("Total written " + bytesWritten.addAndGet(written));
         return written;
     }
 
@@ -198,6 +206,7 @@ public class InternalNioOutputBuffer ext
 
         if (length == 0) return;
 
+        System.out.println("addToBB");
         // Try to flush any data in the socket's write buffer first
         boolean dataLeft = flushBuffer(isBlocking());
 



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


Mime
View raw message