]> granicus.if.org Git - apache/commitdiff
* server/util_filter.c (ap_save_brigade): Handle an ENOTIMPL setaside
authorJoe Orton <jorton@apache.org>
Sun, 26 Sep 2004 15:52:51 +0000 (15:52 +0000)
committerJoe Orton <jorton@apache.org>
Sun, 26 Sep 2004 15:52:51 +0000 (15:52 +0000)
function correctly.

* modules/generators/mod_cgi.c (cgi_handler): Revert r1.169,
unnecessary CGI bucket lifetime kludge.

PR: 31247

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

modules/generators/mod_cgi.c
server/util_filter.c

index 89d833a8c159179f389ddc0b0611ccc3acfc1791..66fbe5f40145005d7fe88926068cac7e73450666 100644 (file)
@@ -905,10 +905,7 @@ static int cgi_handler(request_rec *r)
     apr_file_pipe_timeout_set(script_in, 0);
     apr_file_pipe_timeout_set(script_err, 0);
     
-    /* if r is a subrequest, ensure that the bucket only references
-     * r->main, since it may last longer than the subreq. */
-    b = cgi_bucket_create(r->main ? r->main : r, script_in, script_err,
-                          c->bucket_alloc);
+    b = cgi_bucket_create(r, script_in, script_err, c->bucket_alloc);
 #else
     b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
 #endif
index 05c81063b4621f1c9c3562f2012f6ca5e49ffa48..a294248248999357e8b0dedb30120e14ce39e13b 100644 (file)
@@ -546,10 +546,21 @@ AP_DECLARE(apr_status_t) ap_save_brigade(ap_filter_t *f,
          e = APR_BUCKET_NEXT(e))
     {
         rv = apr_bucket_setaside(e, p);
-        if (rv != APR_SUCCESS
-            /* ### this ENOTIMPL will go away once we implement setaside
-               ### for all bucket types. */
-            && rv != APR_ENOTIMPL) {
+
+        /* If the bucket type does not implement setaside, then
+         * (hopefully) morph it into a bucket type which does, and set
+         * *that* aside... */
+        if (rv == APR_ENOTIMPL) {
+            const char *s;
+            apr_size_t n;
+
+            rv = apr_bucket_read(e, &s, &n, APR_BLOCK_READ);
+            if (rv == APR_SUCCESS) {
+                rv = apr_bucket_setaside(e, p);
+            }
+        }
+
+        if (rv != APR_SUCCESS) {
             return rv;
         }
     }