Author: markt
Date: Fri Aug 12 08:29:13 2011
New Revision: 1157008

URL: http://svn.apache.org/viewvc?rev=1157008&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51324
Improve handling of exceptions when flushing the response buffer to ensure that 
the doFlush flag does not get stuck in the enabled state.
Patch by Jeremy Norris.

Modified:
    tomcat/tc5.5.x/trunk/STATUS.txt
    
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/connector/OutputBuffer.java
    tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml

Modified: tomcat/tc5.5.x/trunk/STATUS.txt
URL: 
http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/STATUS.txt?rev=1157008&r1=1157007&r2=1157008&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/STATUS.txt (original)
+++ tomcat/tc5.5.x/trunk/STATUS.txt Fri Aug 12 08:29:13 2011
@@ -102,14 +102,6 @@ PATCHES PROPOSED TO BACKPORT:
   +1: markt
   -1:
 
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51324
-  Improve handling of exceptions when flushing the response buffer to
-  ensure that the doFlush flag does not get stuck in the enabled state.
-  Patch by Jeremy Norris.
-  http://svn.apache.org/viewvc?rev=1133014&view=rev
-  +1: kkolinko, markt, kfujino
-  -1:
-
 * Fix various sendfile issues. CVE-2011-2526
   This is a port of r1145380, r1145694 and r1146005
   http://people.apache.org/~markt/patches/2011-07-13-cve-2011-2526-tc5.patch

Modified: 
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/connector/OutputBuffer.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/connector/OutputBuffer.java?rev=1157008&r1=1157007&r2=1157008&view=diff
==============================================================================
--- 
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/connector/OutputBuffer.java
 (original)
+++ 
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/connector/OutputBuffer.java
 Fri Aug 12 08:29:13 2011
@@ -237,6 +237,7 @@ public class OutputBuffer extends Writer
         cb.recycle();
         bb.recycle(); 
         closed = false;
+        doFlush = false;
         suspended = false;
         
         if (conv!= null) {
@@ -315,19 +316,22 @@ public class OutputBuffer extends Writer
             return;
 
         doFlush = true;
-        if (initial) {
-            // If the buffers are empty, commit the response header
-            coyoteResponse.sendHeaders();
-            initial = false;
-        }
-        if (state == CHAR_STATE) {
-            cb.flushBuffer();
-            bb.flushBuffer();
-            state = BYTE_STATE;
-        } else if (state == BYTE_STATE) {
-            bb.flushBuffer();
+        try {
+            if (initial) {
+                // If the buffers are empty, commit the response header
+                coyoteResponse.sendHeaders();
+                initial = false;
+            }
+            if (state == CHAR_STATE) {
+                cb.flushBuffer();
+                bb.flushBuffer();
+                state = BYTE_STATE;
+            } else if (state == BYTE_STATE) {
+                bb.flushBuffer();
+            }
+        } finally {
+            doFlush = false;
         }
-        doFlush = false;
 
         if (realFlush) {
             coyoteResponse.action(ActionCode.ACTION_CLIENT_FLUSH, 

Modified: tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml?rev=1157008&r1=1157007&r2=1157008&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml (original)
+++ tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml Fri Aug 12 
08:29:13 2011
@@ -61,6 +61,11 @@
         MemoryUserDatabase via JMX. (markt)
       </fix>
       <fix>
+        <bug>51324</bug>: Improve handling of exceptions when flushing the
+        response buffer to ensure that the doFlush flag does not get stuck in
+        the enabled state. Patch provided by Jeremy Norris. (kkolinko)
+      </fix>
+      <fix>
         <bug>51403</bug>: Avoid NullPointerException in JULI FileHandler if
         formatter is misconfigured. (kkolinko)
       </fix>



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

Reply via email to