]> granicus.if.org Git - apache/commitdiff
If this is a subrequest, register the cleanup against
authorBill Stoddard <stoddard@apache.org>
Mon, 1 Apr 2002 16:09:46 +0000 (16:09 +0000)
committerBill Stoddard <stoddard@apache.org>
Mon, 1 Apr 2002 16:09:46 +0000 (16:09 +0000)
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

index 650dd7d4c278ce66dd27993339df05b71506cbb4..b82c89ef0a375e1c5075580ac879f166dd20c1ab 100644 (file)
@@ -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 {