*** modules/cache/cache_storage.c 2007-09-04 06:35:36.000000000 +0200 --- modules/cache/cache_storage.c 2008-04-26 12:28:50.144662400 +0200 *************** *** 205,211 **** int fresh; if (list->provider->recall_headers(h, r) != APR_SUCCESS) { ! /* TODO: Handle this error */ return DECLINED; } --- 205,214 ---- int fresh; if (list->provider->recall_headers(h, r) != APR_SUCCESS) { ! ! /* We got an error so before leaving we have to close potential opened files */ ! list->provider->recall_cleanup(h); ! return DECLINED; } *************** *** 257,262 **** --- 260,269 ---- ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, "cache_select_url(): Vary header mismatch."); + + /* We got an error so before leaving we have to close potential opened files */ + list->provider->recall_cleanup(h); + return DECLINED; } } *************** *** 330,340 **** --- 337,355 ---- } case DECLINED: { /* try again with next cache type */ + + /* We got an error so switching to the next provider we have to close potential opened files */ + list->provider->recall_cleanup(h); + list = list->next; continue; } default: { /* oo-er! an error */ + + /* We got an error so before leaving we have to close potential opened files */ + list->provider->recall_cleanup(h); + return rv; } } *** modules/cache/mod_cache.h 2007-05-17 16:03:04.000000000 +0200 --- modules/cache/mod_cache.h 2008-04-26 12:31:07.721906900 +0200 *************** *** 206,211 **** --- 206,214 ---- int (*open_entity) (cache_handle_t *h, request_rec *r, const char *urlkey); int (*remove_url) (cache_handle_t *h, apr_pool_t *p); + + /* this was added to close potential file handles open by the provider */ + void (*recall_cleanup) (cache_handle_t *h); } cache_provider; /* A linked-list of authn providers. */ *** modules/cache/mod_disk_cache.c 2007-12-29 09:28:58.000000000 +0100 --- modules/cache/mod_disk_cache.c 2008-04-26 13:42:16.217056500 +0200 *************** *** 1072,1077 **** --- 1072,1095 ---- } /* + * On error, this function close handles potentialy opened by previous calls to this module + */ + void recall_cleanup(cache_handle_t *h) + { + disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj; + if (dobj->hfd) + apr_file_close(dobj->hfd); + + dobj->hfd = NULL; + + if (dobj->fd) + apr_file_close(dobj->fd); + + dobj->fd = NULL; + } + + + /* * mod_disk_cache configuration directives handlers. */ static const char *************** *** 1172,1177 **** --- 1190,1196 ---- &create_entity, &open_entity, &remove_url, + &recall_cleanup, }; static void disk_cache_register_hook(apr_pool_t *p) *** modules/cache/mod_mem_cache.c 2007-09-04 06:39:58.000000000 +0200 --- modules/cache/mod_mem_cache.c 2008-04-26 12:43:28.419699400 +0200 *************** *** 955,960 **** --- 955,968 ---- {NULL} }; + /* + * On error, this function should close opened handles but we have nothing to do + */ + void recall_cleanup(cache_handle_t *h) + { + } + + static const cache_provider cache_mem_provider = { &remove_entity, *************** *** 965,970 **** --- 973,979 ---- &create_mem_entity, &open_entity, &remove_url, + &recall_cleanup, }; static const cache_provider cache_fd_provider = *************** *** 977,982 **** --- 986,992 ---- &create_fd_entity, &open_entity, &remove_url, + &recall_cleanup, }; static void register_hooks(apr_pool_t *p)