Index: modules/cache/mod_cache.c =================================================================== --- modules/cache/mod_cache.c (revision 685114) +++ modules/cache/mod_cache.c (working copy) @@ -296,7 +296,31 @@ return ap_pass_brigade(f->next, bb); } +static int cache_store_content(cache_request_rec *cache, request_rec *r, apr_bucket_brigade *in) +{ + int rv = !OK; + apr_bucket *e = APR_BRIGADE_LAST(in); + ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + "cache: store - content %s", r->uri); + rv = cache->provider->store_body(cache->handle, r, in); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server, + "cache: Cache provider's store_body failed!"); + return rv; + } + if (APR_BUCKET_IS_EOS(e)) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + "cache: store - eos bucket %s", r->uri); + rv = cache->provider->store_headers(cache->handle, r, cache->info); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server, + "cache: Cache provider's store_headers failed!"); + } + } + return rv; +} + /* * CACHE_SAVE filter * --------------- @@ -363,10 +387,10 @@ /* pass the brigades into the cache, then pass them * up the filter stack */ - rv = cache->provider->store_body(cache->handle, r, in); + ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + "cache: store - checked content %s", r->uri); + rv = cache_store_content(cache,r, in); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server, - "cache: Cache provider's store_body failed!"); ap_remove_output_filter(f); } return ap_pass_brigade(f->next, in); @@ -763,15 +787,10 @@ ap_cache_accept_headers(cache->handle, r, 1); } - /* Write away header information to cache. It is possible that we are - * trying to update headers for an entity which has already been cached. - * - * This may fail, due to an unwritable cache area. E.g. filesystem full, - * permissions problems or a read-only (re)mount. This must be handled - * later. + /* Save the cache headers information for an eventual write. + * We dont come this way again. */ - rv = cache->provider->store_headers(cache->handle, r, info); - + cache->info = info; /* Did we just update the cached headers on a revalidated response? * * If so, we can now decide what to serve to the client. This is done in @@ -783,6 +802,10 @@ apr_bucket *bkt; int status; + ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + "cache: store - save headers %s", r->uri); + rv = cache->provider->store_headers(cache->handle, r, info); + bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); /* Restore the original request headers and see if we need to @@ -826,21 +849,12 @@ return ap_pass_brigade(f->next, bb); } - if(rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server, - "cache: store_headers failed"); - ap_remove_output_filter(f); - - return ap_pass_brigade(f->next, in); - } - - rv = cache->provider->store_body(cache->handle, r, in); + ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + "cache: store - first time %s", r->uri); + rv = cache_store_content(cache, r, in); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server, - "cache: store_body failed"); ap_remove_output_filter(f); } - return ap_pass_brigade(f->next, in); }