You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2010/11/06 23:12:41 UTC

svn commit: r1032167 - in /httpd/httpd/trunk: include/http_config.h server/config.c server/log.c server/util.c server/util_mutex.c

Author: sf
Date: Sat Nov  6 22:12:41 2010
New Revision: 1032167

URL: http://svn.apache.org/viewvc?rev=1032167&view=rev
Log:
Add a generic pool cleanup function that sets a pointer to NULL and use
it to replace various pool cleanup functions.

Modified:
    httpd/httpd/trunk/include/http_config.h
    httpd/httpd/trunk/server/config.c
    httpd/httpd/trunk/server/log.c
    httpd/httpd/trunk/server/util.c
    httpd/httpd/trunk/server/util_mutex.c

Modified: httpd/httpd/trunk/include/http_config.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_config.h?rev=1032167&r1=1032166&r2=1032167&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_config.h (original)
+++ httpd/httpd/trunk/include/http_config.h Sat Nov  6 22:12:41 2010
@@ -1243,6 +1243,14 @@ AP_DECLARE_HOOK(int,quick_handler,(reque
  */
 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

Modified: httpd/httpd/trunk/server/config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=1032167&r1=1032166&r2=1032167&view=diff
==============================================================================
--- httpd/httpd/trunk/server/config.c (original)
+++ httpd/httpd/trunk/server/config.c Sat Nov  6 22:12:41 2010
@@ -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++) {

Modified: httpd/httpd/trunk/server/log.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/log.c?rev=1032167&r1=1032166&r2=1032167&view=diff
==============================================================================
--- httpd/httpd/trunk/server/log.c (original)
+++ httpd/httpd/trunk/server/log.c Sat Nov  6 22:12:41 2010
@@ -196,16 +196,6 @@ AP_DECLARE(apr_file_t *) ap_piped_log_wr
     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_
      * 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.

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1032167&r1=1032166&r2=1032167&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Sat Nov  6 22:12:41 2010
@@ -2248,3 +2248,9 @@ AP_DECLARE(int) ap_request_has_body(requ
                 );
     return has_body;
 }
+
+AP_DECLARE(apr_status_t) ap_pool_cleanup_set_null(void *data_)
+{
+    void **ptr = (void **)data_;
+    *ptr = NULL;
+}

Modified: httpd/httpd/trunk/server/util_mutex.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_mutex.c?rev=1032167&r1=1032166&r2=1032167&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_mutex.c (original)
+++ httpd/httpd/trunk/server/util_mutex.c Sat Nov  6 22:12:41 2010
@@ -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(ap
     }
 
     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);