From: Stefan Fritsch Date: Sat, 6 Nov 2010 22:12:41 +0000 (+0000) Subject: Add a generic pool cleanup function that sets a pointer to NULL and use X-Git-Tag: 2.3.9~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=286c8622b6c3a85d59ac47c6df857a298b222d6a;p=thirdparty%2Fapache%2Fhttpd.git Add a generic pool cleanup function that sets a pointer to NULL and use it to replace various pool cleanup functions. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1032167 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/http_config.h b/include/http_config.h index 095880d918d..a2f64706135 100644 --- a/include/http_config.h +++ b/include/http_config.h @@ -1243,6 +1243,14 @@ AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri)) */ AP_DECLARE_HOOK(void,optional_fn_retrieve,(void)) +/** + * A generic pool cleanup that will reset a pointer to NULL. For use with + * apr_pool_cleanup_register. + * @param data The address of the pointer + * @return APR_SUCCESS + */ +AP_DECLARE(apr_status_t) ap_pool_cleanup_set_null(void *data); + #ifdef __cplusplus } #endif diff --git a/server/config.c b/server/config.c index a1fb2c9d1ad..7c01b5b2577 100644 --- a/server/config.c +++ b/server/config.c @@ -471,19 +471,13 @@ struct ap_mod_list_struct { const command_rec *cmd; }; -static apr_status_t reload_conf_hash(void *baton) -{ - ap_config_hash = NULL; - return APR_SUCCESS; -} - static void rebuild_conf_hash(apr_pool_t *p, int add_prelinked) { module **m; ap_config_hash = apr_hash_make(p); - apr_pool_cleanup_register(p, NULL, reload_conf_hash, + apr_pool_cleanup_register(p, &ap_config_hash, ap_pool_cleanup_set_null, apr_pool_cleanup_null); if (add_prelinked) { for (m = ap_prelinked_modules; *m != NULL; m++) { diff --git a/server/log.c b/server/log.c index 4b23d742bfa..ec0a92aea15 100644 --- a/server/log.c +++ b/server/log.c @@ -196,16 +196,6 @@ AP_DECLARE(apr_file_t *) ap_piped_log_write_fd(piped_log *pl) return pl->write_fd; } -/* clear_handle_list() is called when plog is cleared; at that - * point we need to forget about our old list of pipe read - * handles. We let the plog cleanups close the actual pipes. - */ -static apr_status_t clear_handle_list(void *v) -{ - read_handles = NULL; - return APR_SUCCESS; -} - /* remember to close this handle in the child process * * On Win32 this makes zero sense, because we don't @@ -459,7 +449,7 @@ int ap_open_logs(apr_pool_t *pconf, apr_pool_t *p /* plog */, * between log phases, so we don't mind losing stderr's * read_handle a little bit early. */ - apr_pool_cleanup_register(p, NULL, clear_handle_list, + apr_pool_cleanup_register(p, &read_handles, ap_pool_cleanup_set_null, apr_pool_cleanup_null); /* HERE we need a stdout log that outlives plog. diff --git a/server/util.c b/server/util.c index faeda43c50b..c4799b39338 100644 --- a/server/util.c +++ b/server/util.c @@ -2248,3 +2248,9 @@ AP_DECLARE(int) ap_request_has_body(request_rec *r) ); return has_body; } + +AP_DECLARE(apr_status_t) ap_pool_cleanup_set_null(void *data_) +{ + void **ptr = (void **)data_; + *ptr = NULL; +} diff --git a/server/util_mutex.c b/server/util_mutex.c index ad3833b14ff..d3f6674af51 100644 --- a/server/util_mutex.c +++ b/server/util_mutex.c @@ -139,12 +139,6 @@ typedef struct { */ static apr_hash_t *mxcfg_by_type; -static apr_status_t cleanup_mx_hash(void *dummy) -{ - mxcfg_by_type = NULL; - return APR_SUCCESS; -} - AP_DECLARE_NONSTD(void) ap_mutex_init(apr_pool_t *p) { mutex_cfg_t *def; @@ -154,7 +148,8 @@ AP_DECLARE_NONSTD(void) ap_mutex_init(apr_pool_t *p) } mxcfg_by_type = apr_hash_make(p); - apr_pool_cleanup_register(p, NULL, cleanup_mx_hash, apr_pool_cleanup_null); + apr_pool_cleanup_register(p, &mxcfg_by_type, ap_pool_cleanup_set_null, + apr_pool_cleanup_null); /* initialize default mutex configuration */ def = apr_pcalloc(p, sizeof *def);