From: Jim Jagielski Date: Mon, 27 Sep 2010 17:10:18 +0000 (+0000) Subject: No leakie X-Git-Tag: 2.3.9~411 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1859552cc9c741e41d2658b330ea83f8f8a12cf;p=apache No leakie git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1001819 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/slotmem/mod_slotmem_shm.c b/modules/slotmem/mod_slotmem_shm.c index 92c011e9ef..764bae8bba 100644 --- a/modules/slotmem/mod_slotmem_shm.c +++ b/modules/slotmem/mod_slotmem_shm.c @@ -16,6 +16,9 @@ /* Memory handler for a shared memory divided in slot. * This one uses shared memory. + * + * Shared memory is cleaned-up for each restart, graceful or + * otherwise. */ #include "ap_slotmem.h" @@ -184,17 +187,20 @@ static void restore_slotmem(void *ptr, const char *name, apr_size_t size, static apr_status_t cleanup_slotmem(void *param) { ap_slotmem_instance_t **mem = param; - apr_pool_t *pool = NULL; if (*mem) { ap_slotmem_instance_t *next = *mem; - pool = next->gpool; + apr_pool_t *p = next->gpool; while (next) { store_slotmem(next); apr_shm_destroy((apr_shm_t *)next->shm); next = next->next; } - apr_pool_destroy(pool); + apr_pool_destroy(p); + } else { + /* If shared mem was never called, then just remove + * the global pool */ + apr_pool_destroy(gpool); } return APR_SUCCESS; } @@ -593,14 +599,17 @@ static int post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, void *data; const char *userdata_key = "slotmem_shm_post_config"; + slotmem_shm_initialize_cleanup(p); + + /* keep this around for possible future usage */ apr_pool_userdata_get(&data, userdata_key, s->process->pool); if (!data) { apr_pool_userdata_set((const void *)1, userdata_key, apr_pool_cleanup_null, s->process->pool); + /* Do Stuff */ return OK; } - slotmem_shm_initialize_cleanup(p); return OK; }