From d1da525e055237b2a0d9fa4a11a85d22e4a2ed23 Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Tue, 12 Oct 2010 20:43:51 +0000 Subject: [PATCH] Restore the apr_brigade_insert_file() call to within recall_body(), as the 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 | 13 ++++++++----- modules/cache/mod_disk_cache.c | 4 +--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index e3aafd4643..a86d0adefa 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -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); diff --git a/modules/cache/mod_disk_cache.c b/modules/cache/mod_disk_cache.c index 9c7ccb6c0b..08ad732118 100644 --- a/modules/cache/mod_disk_cache.c +++ b/modules/cache/mod_disk_cache.c @@ -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; -- 2.50.1