Commit 6016626f authored by Bill Stoddard's avatar Bill Stoddard
Browse files

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
parent d470bfa7
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -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;
}