tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1089531 - in /tomcat/trunk: java/org/apache/coyote/http11/Http11Processor.java test/org/apache/coyote/http11/TestAbstractHttp11Processor.java webapps/docs/changelog.xml
Date Wed, 06 Apr 2011 16:39:39 GMT
Author: markt
Date: Wed Apr  6 16:39:38 2011
New Revision: 1089531

URL: http://svn.apache.org/viewvc?rev=1089531&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50957
Fix regression in processing of pipe-lined requests.

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
    tomcat/trunk/test/org/apache/coyote/http11/TestAbstractHttp11Processor.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1089531&r1=1089530&r2=1089531&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Wed Apr  6 16:39:38 2011
@@ -314,9 +314,12 @@ public class Http11Processor extends Abs
                 inputBuffer.nextRequest();
                 outputBuffer.nextRequest();
             }
-            
-            //hack keep alive behavior
-            break;
+
+            // If we don't have a pipe-lined request allow this thread to be
+            // used by another connection
+            if (isAsync() || error || inputBuffer.lastValid == 0) {
+                break;
+            }
         }
 
         rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);

Modified: tomcat/trunk/test/org/apache/coyote/http11/TestAbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http11/TestAbstractHttp11Processor.java?rev=1089531&r1=1089530&r2=1089531&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http11/TestAbstractHttp11Processor.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http11/TestAbstractHttp11Processor.java Wed Apr  6
16:39:38 2011
@@ -14,12 +14,14 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.coyote.http11;
 
 import java.io.File;
+import java.io.IOException;
 
+import org.apache.catalina.Context;
 import org.apache.catalina.startup.SimpleHttpClient;
+import org.apache.catalina.startup.TesterServlet;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 
@@ -171,6 +173,66 @@ public class TestAbstractHttp11Processor
     }
 
 
+    public void testPipelining() throws Exception {
+        Tomcat tomcat = getTomcatInstance();
+        
+        // Must have a real docBase - just use temp
+        Context ctxt = tomcat.addContext("",
+                System.getProperty("java.io.tmpdir"));
+        
+        // Add protected servlet
+        Tomcat.addServlet(ctxt, "TesterServlet", new TesterServlet());
+        ctxt.addServletMapping("/foo", "TesterServlet");
+        
+        tomcat.start();
+
+        String requestPart1 =
+            "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF;
+        String requestPart2 =
+            "Host: any" + SimpleHttpClient.CRLF +
+            SimpleHttpClient.CRLF;
+
+        final Client client = new Client();
+        client.setPort(getPort());
+        client.setRequest(new String[] {requestPart1, requestPart2});
+        client.setRequestPause(1000);
+        client.setUseContentLength(true);
+        client.connect();
+
+        Runnable send = new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    client.sendRequest();
+                    client.sendRequest();
+                } catch (InterruptedException e) {
+                    throw new RuntimeException(e);
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        };
+        Thread t = new Thread(send);
+        t.start();
+        
+        // Sleep for 1500 ms which should mean the all of request 1 has been
+        // sent and half of request 2
+        Thread.sleep(1500);
+        
+        // Now read the first response
+        client.readResponse(true);
+        assertFalse(client.isResponse50x());
+        assertTrue(client.isResponse200());
+        assertEquals("OK", client.getResponseBody());
+        
+        // Read the second response. No need to sleep, read will block until
+        // there is data to process
+        client.readResponse(true);
+        assertFalse(client.isResponse50x());
+        assertTrue(client.isResponse200());
+        assertEquals("OK", client.getResponseBody());
+    }
+    
     private static final class Client extends SimpleHttpClient {
         @Override
         public boolean isResponseBodyOK() {

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1089531&r1=1089530&r2=1089531&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Apr  6 16:39:38 2011
@@ -58,6 +58,14 @@
       </update>
     </changelog>
   </subsection>
+  <subsection name="Coyote">
+    <changelog>
+      <fix>
+        <bug>50957</bug>: Fix regression in HTTP BIO connector that triggered
+        errors when processing pipe-lined requests. (markt)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Web applications">
     <changelog>
       <update>



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


Mime
View raw message