]> granicus.if.org Git - apache/commitdiff
Restore the apr_brigade_insert_file() call to within recall_body(), as the
authorGraham Leggett <minfrin@apache.org>
Tue, 12 Oct 2010 20:43:51 +0000 (20:43 +0000)
committerGraham Leggett <minfrin@apache.org>
Tue, 12 Oct 2010 20:43:51 +0000 (20:43 +0000)
function does more than add a single file bucket. Pass an empty brigade
to recall_body(), and prepend the result to the existing output brigade,
the next bucket being eos.

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

modules/cache/mod_cache.c
modules/cache/mod_disk_cache.c

index e3aafd4643522d05456e931b9d88204ca139bc2b..a86d0adefa628836a12b8b92df7da1cedac433b8 100644 (file)
@@ -568,7 +568,7 @@ static int cache_handler(request_rec *r)
  *
  * Deliver cached content (headers and body) up the stack.
  */
-static int cache_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
+static int cache_out_filter(ap_filter_t *f, apr_bucket_brigade *in)
 {
     request_rec *r = f->r;
     apr_bucket *e;
@@ -580,31 +580,34 @@ static int cache_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
                      "CACHE/CACHE_OUT filter enabled while caching is disabled, ignoring");
         ap_remove_output_filter(f);
-        return ap_pass_brigade(f->next, bb);
+        return ap_pass_brigade(f->next, in);
     }
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
                  "cache: running CACHE_OUT filter");
 
     /* clean out any previous response up to EOS, if any */
-    for (e = APR_BRIGADE_FIRST(bb);
-         e != APR_BRIGADE_SENTINEL(bb);
+    for (e = APR_BRIGADE_FIRST(in);
+         e != APR_BRIGADE_SENTINEL(in);
          e = APR_BUCKET_NEXT(e))
     {
         if (APR_BUCKET_IS_EOS(e)) {
+            apr_bucket_brigade *bb = apr_brigade_create(r->pool,
+                    r->connection->bucket_alloc);
 
             /* restore status of cached response */
             r->status = cache->handle->cache_obj->info.status;
 
             /* recall_headers() was called in cache_select() */
             cache->provider->recall_body(cache->handle, r->pool, bb);
+            APR_BRIGADE_PREPEND(in, bb);
 
             /* This filter is done once it has served up its content */
             ap_remove_output_filter(f);
 
             ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
                          "cache: serving %s", r->uri);
-            return ap_pass_brigade(f->next, bb);
+            return ap_pass_brigade(f->next, in);
 
         }
         apr_bucket_delete(e);
index 9c7ccb6c0bd5d3873a49d622db7991b1b5095691..08ad732118dfb914d25dc44b579436bd12a727a3 100644 (file)
@@ -863,9 +863,7 @@ static apr_status_t recall_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_bri
     disk_cache_object_t *dobj = (disk_cache_object_t*) h->cache_obj->vobj;
 
     if (dobj->data.fd) {
-        apr_bucket *e = apr_bucket_file_create(dobj->data.fd, 0,
-                dobj->file_size, p, bb->bucket_alloc);
-        APR_BRIGADE_INSERT_HEAD(bb, e);
+        apr_brigade_insert_file(bb, dobj->data.fd, 0, dobj->file_size, p);
     }
 
     return APR_SUCCESS;