]> granicus.if.org Git - apache/commitdiff
Fix segfault at startup when the startup fails before running the post config
authorBill Stoddard <stoddard@apache.org>
Wed, 5 Jun 2002 21:47:58 +0000 (21:47 +0000)
committerBill Stoddard <stoddard@apache.org>
Wed, 5 Jun 2002 21:47:58 +0000 (21:47 +0000)
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

modules/experimental/mod_mem_cache.c

index f29c076bca940063de7d2335552ad061b4edff86..bf6441edd80cd32d58918af8be56718f14cb87d8 100644 (file)
@@ -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;
 }