]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Add a generic pool cleanup function that sets a pointer to NULL and use
authorStefan Fritsch <sf@apache.org>
Sat, 6 Nov 2010 22:12:41 +0000 (22:12 +0000)
committerStefan Fritsch <sf@apache.org>
Sat, 6 Nov 2010 22:12:41 +0000 (22:12 +0000)
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

include/http_config.h
server/config.c
server/log.c
server/util.c
server/util_mutex.c

index 095880d918d062c7193c524d61c91789f04d7b04..a2f647061350e37dcc4cdb7d5a8ad8706f0c2a90 100644 (file)
@@ -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
index a1fb2c9d1addfe5c4fb6f71930e10bd361dc8992..7c01b5b2577fff4ac6829537a76f208ffa47271f 100644 (file)
@@ -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++) {
index 4b23d742bfaf97a6212371dc47d6d74a44f063cf..ec0a92aea15ec4f066a47acca9357b4e4cac3190 100644 (file)
@@ -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.
index faeda43c50b97b4b352a23b0a2dc2119a82357b2..c4799b393385fcaaa934bf5e1038a8a2ac34847a 100644 (file)
@@ -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;
+}
index ad3833b14ff212117f98f5e99d3d1b6341ec4b06..d3f6674af51617a2987a090fe83e1b41f0f6ba67 100644 (file)
@@ -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);