On Wed, 22 Jan 2003, Cliff Woolley wrote:
> It's unlikely that this problem has anything to do with APR; it's quite
> likely just a (newly uncovered) bug in mod_file_cache.
Looks that way. 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. :-/
The attached patch *should* fix it, though it's tested only to compile at
this point. I'm mainly looking for another set of eyes to help verify
that I haven't missed anything... wouldn't want to introduce any memory or
fd leaks.
--Cliff
? build/ltmain.sh
Index: modules/cache/mod_file_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/cache/mod_file_cache.c,v
retrieving revision 1.74
diff -u -d -r1.74 mod_file_cache.c
--- modules/cache/mod_file_cache.c 23 Nov 2002 21:18:16 -0000 1.74
+++ modules/cache/mod_file_cache.c 22 Jan 2003 05:36:32 -0000
@@ -162,30 +162,6 @@
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 @@
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)