From f0e6550bebd48a7596e5c451ce3350507b0b187f Mon Sep 17 00:00:00 2001 From: remm Date: Mon, 30 Apr 2007 23:39:41 +0000 Subject: [PATCH] - Obvious typo in didRead. Ooops. Maybe Eclipse did that. - 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/java/org/apache/catalina/connector/InputBuffer.java b/java/org/apache/catalina/connector/InputBuffer.java index 5f1796078..ca188a4bc 100644 --- a/java/org/apache/catalina/connector/InputBuffer.java +++ b/java/org/apache/catalina/connector/InputBuffer.java @@ -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; } -- 2.11.0