You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2018/04/13 07:58:52 UTC

svn commit: r1829038 - in /httpd/httpd/trunk: CHANGES modules/filters/mod_xml2enc.c

Author: ylavic
Date: Fri Apr 13 07:58:51 2018
New Revision: 1829038

URL: http://svn.apache.org/viewvc?rev=1829038&view=rev
Log:
mod_xml2enc: Fix forwarding of error metadata/responses. PR 62180.

All meta buckets are now aggregated (besides FLUSH) and forwarded down
the chain, and the output filter bails out on EOS.

Proposed by: Micha Lenk <micha lenk.info>


Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/filters/mod_xml2enc.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1829038&r1=1829037&r2=1829038&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Fri Apr 13 07:58:51 2018
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.1
 
+  *) mod_xml2enc: Fix forwarding of error metadata/responses. PR 62180.
+     [Micha Lenk <micha lenk.info>, Yann Ylavic]
+
   *) mod_proxy_http: Add new worker parameter 'responsefieldsize' to
      allow maximum HTTP response header size to be increased past 8192 
      bytes.  PR62199.  [Hank Ibell <hwibell gmail.com>]

Modified: httpd/httpd/trunk/modules/filters/mod_xml2enc.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_xml2enc.c?rev=1829038&r1=1829037&r2=1829038&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_xml2enc.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_xml2enc.c Fri Apr 13 07:58:51 2018
@@ -309,6 +309,7 @@ static apr_status_t xml2enc_ffunc(ap_fil
     apr_bucket* b;
     apr_bucket* bstart;
     apr_size_t insz = 0;
+    int pending_meta = 0;
     char *ctype;
     char *p;
 
@@ -400,16 +401,35 @@ static apr_status_t xml2enc_ffunc(ap_fil
         ctx->bytes = 0;
         if (APR_BUCKET_IS_METADATA(b)) {
             APR_BUCKET_REMOVE(b);
+            APR_BRIGADE_INSERT_TAIL(ctx->bbnext, b);
+            /* This resource filter is over on EOS */
             if (APR_BUCKET_IS_EOS(b)) {
-                /* send remaining data */
-                APR_BRIGADE_INSERT_TAIL(ctx->bbnext, b);
-                return ap_fflush(f->next, ctx->bbnext);
-            } else if (APR_BUCKET_IS_FLUSH(b)) {
-                ap_fflush(f->next, ctx->bbnext);
+                ap_remove_output_filter(f);
+                APR_BRIGADE_CONCAT(ctx->bbnext, bb);
+                rv = ap_pass_brigade(f->next, ctx->bbnext);
+                apr_brigade_cleanup(ctx->bbnext);
+                return rv;
             }
-            apr_bucket_destroy(b);
+            /* Besides FLUSH, aggregate meta buckets to send
+             * them at once below.
+             */
+            pending_meta = 1;
+            if (!APR_BUCKET_IS_FLUSH(b)) {
+                continue;
+            }
+        }
+        if (pending_meta) {
+            pending_meta = 0;
+            /* passing meta bucket down the chain */
+            rv = ap_pass_brigade(f->next, ctx->bbnext);
+            apr_brigade_cleanup(ctx->bbnext);
+            if (rv != APR_SUCCESS) {
+                return rv;
+            }
+            continue;
         }
-        else {        /* data bucket */
+        /* data bucket */
+        {
             char* buf;
             apr_size_t bytes = 0;
             char fixbuf[BUFLEN];
@@ -514,8 +534,7 @@ static apr_status_t xml2enc_ffunc(ap_fil
                         if (rv != APR_SUCCESS)
                             ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, f->r, APLOGNO(01446)
                                           "ap_fflush failed");
-                        else
-                            rv = ap_pass_brigade(f->next, ctx->bbnext);
+                        apr_brigade_cleanup(ctx->bbnext);
                     }
                 }
             } else {