From ca3b3ea5f123a10cfbb5cead5925f9572a613fcf Mon Sep 17 00:00:00 2001 From: Bill Stoddard Date: Mon, 1 Apr 2002 16:09:46 +0000 Subject: [PATCH] If this is a subrequest, register the cleanup against the main request. This will prevent the cache object from being cleaned up from under the request after the subrequest is destroyed. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94359 13f79535-47bb-0310-9956-ffa450edef68 --- modules/experimental/mod_mem_cache.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/experimental/mod_mem_cache.c b/modules/experimental/mod_mem_cache.c index 650dd7d4c2..b82c89ef0a 100644 --- a/modules/experimental/mod_mem_cache.c +++ b/modules/experimental/mod_mem_cache.c @@ -429,12 +429,24 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *type, cons APR_HASH_KEY_STRING); if (obj) { if (obj->complete) { + request_rec *rmain, *rtmp; + #ifdef USE_ATOMICS apr_atomic_inc(&obj->refcount); #else obj->refcount++; #endif - apr_pool_cleanup_register(r->pool, obj, decrement_refcount, + /* If this is a subrequest, register the cleanup against + * the main request. This will prevent the cache object + * from being cleaned up from under the request after the + * subrequest is destroyed. + */ + rtmp = r; + while (rtmp) { + rmain = rtmp; + rtmp = rmain->main; + } + apr_pool_cleanup_register(rmain->pool, obj, decrement_refcount, apr_pool_cleanup_null); } else { -- 2.50.1