From: Bill Stoddard Date: Wed, 5 Jun 2002 21:47:58 +0000 (+0000) Subject: Fix segfault at startup when the startup fails before running the post config X-Git-Tag: 2.0.37~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=99d058a79dfd5f2b528aec9c5e5de889d2478178;p=apache Fix segfault at startup when the startup fails before running the post config hook. We were setting the hash table cleanup in the create_per_server_config hook and allocating the hash table in the post config hook. Move the register_cleanup to the post_config hook git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95532 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/experimental/mod_mem_cache.c b/modules/experimental/mod_mem_cache.c index f29c076bca..bf6441edd8 100644 --- a/modules/experimental/mod_mem_cache.c +++ b/modules/experimental/mod_mem_cache.c @@ -288,15 +288,8 @@ static apr_status_t cleanup_cache_mem(void *sconfv) */ static void *create_cache_config(apr_pool_t *p, server_rec *s) { - int threaded_mpm; - sconf = apr_pcalloc(p, sizeof(mem_cache_conf)); - ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded_mpm); - if (threaded_mpm) { - apr_thread_mutex_create(&sconf->lock, APR_THREAD_MUTEX_DEFAULT, p); - } - sconf->min_cache_object_size = DEFAULT_MIN_CACHE_OBJECT_SIZE; sconf->max_cache_object_size = DEFAULT_MAX_CACHE_OBJECT_SIZE; /* Number of objects in the cache */ @@ -306,8 +299,6 @@ static void *create_cache_config(apr_pool_t *p, server_rec *s) sconf->max_cache_size = DEFAULT_MAX_CACHE_SIZE; sconf->cache_size = 0; - apr_pool_cleanup_register(p, sconf, cleanup_cache_mem, apr_pool_cleanup_null); - return sconf; } @@ -880,7 +871,14 @@ static apr_status_t write_body(cache_handle_t *h, request_rec *r, apr_bucket_bri static int mem_cache_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { + int threaded_mpm; + ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded_mpm); + if (threaded_mpm) { + apr_thread_mutex_create(&sconf->lock, APR_THREAD_MUTEX_DEFAULT, p); + } sconf->cacheht = cache_hash_make(sconf->max_object_cnt); + apr_pool_cleanup_register(p, sconf, cleanup_cache_mem, apr_pool_cleanup_null); + return OK; }