From: Cliff Woolley Date: Thu, 23 Jan 2003 00:55:47 +0000 (+0000) Subject: Fix a problem whereby multiple MMapFile directives would cause a segfault X-Git-Tag: pre_ajp_proxy~2220 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b060bce5f52d91dd753f134e75e9f174602dadd;p=apache Fix a problem whereby multiple MMapFile directives would cause a segfault on startup. mod_file_cache keeps a hash table in the cmd->pool and puts an entry in that hash table for each of its files and mmaps, all of which are opened into cmd->pool. But it registered a cleanup on cmd->pool that would walk the hash table and close each file and delete each mmap, even though by the time that happened those things would have been done already anyway by the files' and mmaps' own cleanups on cmd->pool. So it was deleting mmaps that were already cleaned up and closing files that were already cleaned up in all cases. This has never been valid... amazed it ever worked. But apparently the true bogosity wasn't revealed until the new mmap cleanup code went into APR. PR: 16313 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@98463 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 3cc218c51d..11e6e6e0ca 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) mod_file_cache: fixed a segfault when multiple MMapFile directives + were used. PR 16313. [Cliff Woolley] + *) Move RFC 1413 ident requests from core to new module mod_ident. [André Malo] diff --git a/modules/cache/mod_file_cache.c b/modules/cache/mod_file_cache.c index 37209e2744..89b3547d1d 100644 --- a/modules/cache/mod_file_cache.c +++ b/modules/cache/mod_file_cache.c @@ -162,30 +162,6 @@ static void *create_server_config(apr_pool_t *p, server_rec *s) return sconf; } -static apr_status_t cleanup_file_cache(void *sconfv) -{ - a_server_config *sconf = sconfv; - apr_pool_t *p = apr_hash_pool_get(sconf->fileht); - a_file *file; - apr_hash_index_t *hi; - - /* Iterate over the file hash table and clean up each entry */ - for (hi = apr_hash_first(p, sconf->fileht); hi; hi=apr_hash_next(hi)) { - apr_hash_this(hi, NULL, NULL, (void **)&file); -#if APR_HAS_MMAP - if (file->is_mmapped) { - apr_mmap_delete(file->mm); - } -#endif -#if APR_HAS_SENDFILE - if (!file->is_mmapped) { - apr_file_close(file->file); - } -#endif - } - return APR_SUCCESS; -} - static void cache_the_file(cmd_parms *cmd, const char *filename, int mmap) { a_server_config *sconf; @@ -274,10 +250,6 @@ static void cache_the_file(cmd_parms *cmd, const char *filename, int mmap) sconf = ap_get_module_config(cmd->server->module_config, &file_cache_module); apr_hash_set(sconf->fileht, new_file->filename, strlen(new_file->filename), new_file); - if (apr_hash_count(sconf->fileht) == 1) { - /* first one, register the cleanup */ - apr_pool_cleanup_register(cmd->pool, sconf, cleanup_file_cache, apr_pool_cleanup_null); - } } static const char *cachefilehandle(cmd_parms *cmd, void *dummy, const char *filename)