Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F1502105FE for ; Fri, 3 May 2013 20:34:56 +0000 (UTC) Received: (qmail 42437 invoked by uid 500); 3 May 2013 20:34:56 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 42320 invoked by uid 500); 3 May 2013 20:34:56 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 42309 invoked by uid 99); 3 May 2013 20:34:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 May 2013 20:34:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 May 2013 20:34:54 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A4D022388847 for ; Fri, 3 May 2013 20:34:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1478968 - in /tomcat/trunk: java/org/apache/coyote/http11/ test/org/apache/catalina/nonblocking/ Date: Fri, 03 May 2013 20:34:34 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130503203434.A4D022388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Fri May 3 20:34:34 2013 New Revision: 1478968 URL: http://svn.apache.org/r1478968 Log: Faking of non-blocking reads for BIO. Tweak test case so it relies more on the Servlet API and less on the implementation details of the test so BIO's fake blocking passes. Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java tomcat/trunk/java/org/apache/coyote/http11/InternalInputBuffer.java tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java 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=1478968&r1=1478967&r2=1478968&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Fri May 3 20:34:34 2013 @@ -810,6 +810,8 @@ public abstract class AbstractHttp11Proc ((AtomicBoolean) param).set(asyncStateMachine.isAsyncTimingOut()); } else if (actionCode == ActionCode.ASYNC_IS_ERROR) { ((AtomicBoolean) param).set(asyncStateMachine.isAsyncError()); + } else if (actionCode == ActionCode.AVAILABLE) { + request.setAvailable(inputBuffer.available()); } else if (actionCode == ActionCode.NB_WRITE_INTEREST) { AtomicBoolean isReady = (AtomicBoolean)param; isReady.set(getOutputBuffer().isReady()); Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1478968&r1=1478967&r2=1478968&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Fri May 3 20:34:34 2013 @@ -472,9 +472,6 @@ public class Http11NioProcessor extends log.warn(sm.getString("http11processor.socket.ssl"), e); } } - - } else if (actionCode == ActionCode.AVAILABLE) { - request.setAvailable(inputBuffer.available()); } else if (actionCode == ActionCode.COMET_BEGIN) { comet = true; } else if (actionCode == ActionCode.COMET_END) { Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalInputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalInputBuffer.java?rev=1478968&r1=1478967&r2=1478968&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/InternalInputBuffer.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/InternalInputBuffer.java Fri May 3 20:34:34 2013 @@ -71,6 +71,17 @@ public class InternalInputBuffer extends /** + * Data is always available for blocking IO (if you wait long enough) so + * return a value of 1. Note that the actual value is never used it is only + * tested for == 0 or > 0. + */ + @Override + public int available() { + return 1; + } + + + /** * Read the request line. This function is meant to be used during the * HTTP request header parsing. Do NOT attempt to read the request body * using it. @@ -543,8 +554,7 @@ public class InternalInputBuffer extends @Override protected int nbRead() throws IOException { - // TODO Auto-generated method stub - return 0; + throw new IllegalStateException("This method is unused for BIO"); } Modified: tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java?rev=1478968&r1=1478967&r2=1478968&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java (original) +++ tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java Fri May 3 20:34:34 2013 @@ -57,12 +57,6 @@ public class TestNonBlockingAPI extends public void testNonBlockingRead() throws Exception { Tomcat tomcat = getTomcatInstance(); - // TODO Faking non-blocking reads is not yet implemented for BIO. - if (tomcat.getConnector().getProtocolHandlerClassName().equals( - "org.apache.coyote.http11.Http11Protocol")) { - return; - } - // TODO Non-blocking reads are not yet implemented for APR. if (tomcat.getConnector().getProtocolHandlerClassName().equals( "org.apache.coyote.http11.Http11AprProtocol")) { @@ -294,12 +288,8 @@ public class TestNonBlockingAPI extends listener = new TestReadListener(actx); in.setReadListener(listener); - while (in.isReady()) { - listener.onDataAvailable(); - } + listener.onDataAvailable(); } - - } @WebServlet(asyncSupported = true) @@ -365,12 +355,16 @@ public class TestNonBlockingAPI extends ServletInputStream in = ctx.getRequest().getInputStream(); String s = ""; byte[] b = new byte[8192]; - while (in.isReady()) { - int read = in.read(b); + int read = 0; + do { + read = in.read(b); + if (read == -1) { + break; + } s += new String(b, 0, read); - } + } while (in.isReady()); System.out.println(s); - if ("FINISHED".equals(s)) { + if (s.endsWith("FINISHED")) { ctx.complete(); ctx.getResponse().getWriter().print("OK"); } else { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org