- Obvious typo in didRead. Ooops. Maybe Eclipse did that.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 30 Apr 2007 23:39:41 +0000 (23:39 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 30 Apr 2007 23:39:41 +0000 (23:39 +0000)
- Return 1 for available when using a Comet read and no real read was done (actually, it could well be good enough
  to only use didRead to get an "accurate" available() method, but it could probably be useful for blocking IO).

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

java/org/apache/catalina/connector/InputBuffer.java

index 5f17960..ca188a4 100644 (file)
@@ -101,7 +101,7 @@ public class InputBuffer extends Reader
     /**
      * Flag which if a read was performed.
      */
-    private boolean didRead = false;
+    private boolean didRead = true;
 
 
     /**
@@ -274,12 +274,20 @@ public class InputBuffer extends Reader
             coyoteRequest.action(ActionCode.ACTION_AVAILABLE, null);
             available = (coyoteRequest.getAvailable() > 0) ? 1 : 0;
         }
+        if ((available == 0) && !didRead) {
+            // This is a comet read and no read was done: at least one
+            // read can be made without blocking (in very rare cases, it will
+            // reach the end of the stream, for example if the bytes sent 
+            // were from a next request, or if the request content-length is
+            // wrong)
+            available = 1;
+        }
         return available;
     }
 
 
     public boolean didRead() {
-        return didRead();
+        return didRead;
     }