ASF Bugzilla – Attachment 22441 Details for
Bug 44696
mod_cache sometimes serves old content despite having fetched new content
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
iterate over buckets in a brigade to find eos
patch (text/plain), 4.92 KB, created by
rahul
on 2008-08-13 06:01:10 UTC
(
hide
)
Description:
iterate over buckets in a brigade to find eos
Filename:
MIME Type:
Creator:
rahul
Created:
2008-08-13 06:01:10 UTC
Size:
4.92 KB
patch
obsolete
>Index: modules/cache/mod_cache.c >=================================================================== >--- modules/cache/mod_cache.c (revision 685496) >+++ modules/cache/mod_cache.c (working copy) >@@ -296,7 +296,39 @@ > return ap_pass_brigade(f->next, bb); > } > >+/* >+ * Try storing the body first, and at the end the headers. This is to avoid >+ * the race condition in which another worker reads updated headers which are >+ * not in sync with the body and assumes body is fresh. >+ */ >+static int cache_store_content(cache_request_rec *cache, request_rec *r, apr_bucket_brigade *in) >+{ >+ int rv = !OK; >+ apr_bucket *e; >+ 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; >+ } >+ for (e = APR_BRIGADE_FIRST(in); e != APR_BRIGADE_SENTINEL(in); e = APR_BUCKET_NEXT(e)) { >+ 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!"); >+ } >+ break; >+ } >+ } >+ return rv; >+} >+ > /* > * CACHE_SAVE filter > * --------------- >@@ -363,10 +395,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); >@@ -742,6 +774,11 @@ > } > info->expire = exp; > >+ /* Save the cache headers information for an eventual write. >+ * We dont come this way again. >+ */ >+ cache->info = info; >+ > /* We found a stale entry which wasn't really stale. */ > if (cache->stale_handle) { > /* Load in the saved status and clear the status line. */ >@@ -761,28 +798,21 @@ > > /* Merge in our cached headers. However, keep any updated values. */ > 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. >- */ >- rv = cache->provider->store_headers(cache->handle, r, 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 >- * the same way as with a regular response, but conditions are now checked >- * against the cached or merged response headers. >- */ >- if (cache->stale_handle) { >+ /* we can now decide what to serve to the client. This is done in >+ * the same way as with a regular response, but conditions are now checked >+ * against the cached or merged response headers. >+ */ > apr_bucket_brigade *bb; > apr_bucket *bkt; > int status; > >+ /* Since it is a revalidated response, we only have to save the headers. >+ */ >+ 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,18 +856,10 @@ > 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); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 44696
:
22429
|
22433
|
22434
| 22441