]> granicus.if.org Git - apache/commitdiff
mod_xml2enc: Fix forwarding of error metadata/responses. PR 62180.
authorYann Ylavic <ylavic@apache.org>
Fri, 13 Apr 2018 07:58:51 +0000 (07:58 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 13 Apr 2018 07:58:51 +0000 (07:58 +0000)
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>

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1829038 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/filters/mod_xml2enc.c

diff --git a/CHANGES b/CHANGES
index 4db111242f0a12cf081f1371f7ea53a13378d59d..6057eec2d6f076285b16d4de12dfdee13e75b7c3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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>]
index 72d3741c00e4a5474008c25ba2a7dbcab746d31f..ea7f0842e494f3fee5e2297165d34e0ecb2f236b 100644 (file)
@@ -309,6 +309,7 @@ static apr_status_t xml2enc_ffunc(ap_filter_t* f, apr_bucket_brigade* bb)
     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_filter_t* f, apr_bucket_brigade* bb)
         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;
+            }
+            /* 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;
             }
-            apr_bucket_destroy(b);
+            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_filter_t* f, apr_bucket_brigade* bb)
                         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 {