Commit 65a84f75 authored by William A. Rowe Jr's avatar William A. Rowe Jr
Browse files

  Provide apr_pool_t arg to register_hooks, since anything they do in that
  step -must- be done with a pool that will not outlive the cmd pool, from
  which they may have been dynamically loaded.

  This needs further review, it's committed only as a stopgap for those
  who's builds I broke, sorry.  Review tbc late this evening.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87699 13f79535-47bb-0310-9956-ffa450edef68
parent 5750e947
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -529,10 +529,12 @@ AP_DECLARE(const char *) ap_server_root_relative(apr_pool_t *p, const char *fnam

/**
 * Add a module to the server
 * @param m the module structure of the module to add
 * @deffunc void ap_add_module(module *m)
 * @param m The module structure of the module to add
 * @param p The pool of the same lifetime as the module
 * @deffunc void ap_add_module(module *m, apr_pool_t *p)
 */
AP_DECLARE(void) ap_add_module(module *m);
AP_DECLARE(void) ap_add_module(module *m, apr_pool_t *p);

/**
 * Remove a module from the server.  There are some caveats:
 * when the module is removed, its slot is lost so all the current
@@ -545,10 +547,11 @@ AP_DECLARE(void) ap_add_module(module *m);
AP_DECLARE(void) ap_remove_module(module *m);
/**
 * Add a module to the chained modules list and the list of loaded modules
 * @param m the module structure of the module to add
 * @deffunc void ap_add_loaded_module(module *m)
 * @param m The module structure of the module to add
 * @param p The pool with the same lifetime as the module
 * @deffunc void ap_add_loaded_module(module *m, apr_pool_t *p)
 */
AP_DECLARE(void) ap_add_loaded_module(module *mod);
AP_DECLARE(void) ap_add_loaded_module(module *mod, apr_pool_t *p);
/**
 * Remove a module fromthe chained modules list and the list of loaded modules
 * @param m the module structure of the module to remove
@@ -559,15 +562,17 @@ AP_DECLARE(void) ap_remove_loaded_module(module *mod);
 * Add a module to the list of loaded module based on the name of the
 * module
 * @param name The name of the module
 * @param p The pool valid for the lifetime of the module
 * @return 1 on success, 0 on failure
 * @deffunc int ap_add_named_module(const char *name)
 * @deffunc int ap_add_named_module(const char *name, apr_pool_t *p)
 */
AP_DECLARE(int) ap_add_named_module(const char *name);
AP_DECLARE(int) ap_add_named_module(const char *name, apr_pool_t *p);
/**
 * Clear all of the modules from the loaded module list 
 * @deffunc void ap_add_named_module(void)
 * @param p The pool valid for the lifetime of the modules
 * @deffunc void ap_add_named_module(apr_pool_t *p)
 */
AP_DECLARE(void) ap_clear_module_list(void);
AP_DECLARE(void) ap_clear_module_list(apr_pool_t *p);
/**
 * Find the name of the specified module
 * @param m The module to get the name for
@@ -800,9 +805,10 @@ AP_DECLARE(void) ap_run_rewrite_args(process_rec *process);
/**
 * Run the register hooks function for a specified module
 * @param m The module to run the register hooks function fo
 * @deffunc void ap_register_hooks(module *m)
 * @param p The pool valid for the lifetime of the module
 * @deffunc void ap_register_hooks(module *m, apr_pool_t *p)
 */
AP_DECLARE(void) ap_register_hooks(module *m);
AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p);

/**
 * Setup all virtual hosts
+2 −2
Original line number Diff line number Diff line
@@ -1903,7 +1903,7 @@ static const char *add_module_command(cmd_parms *cmd, void *dummy,
        return err;
    }

    if (!ap_add_named_module(arg)) {
    if (!ap_add_named_module(arg, cmd->pool)) {
	return apr_pstrcat(cmd->pool, "Cannot add module via name '", arg, 
			  "': not in list of loaded modules", NULL);
    }
@@ -1918,7 +1918,7 @@ static const char *clear_module_list_command(cmd_parms *cmd, void *dummy)
        return err;
    }

    ap_clear_module_list();
    ap_clear_module_list(cmd->pool);
    *(ap_directive_t **)dummy = NULL;
    return NULL;
}
+1 −1
Original line number Diff line number Diff line
@@ -298,7 +298,7 @@ static const char *load_module(cmd_parms *cmd, void *dummy,
    /* 
     * Add this module to the Apache core structures
     */
    ap_add_loaded_module(modp);
    ap_add_loaded_module(modp, cmd->pool);

    /* 
     * Register a cleanup in the config apr_pool_t (normally pconf). When
+19 −17
Original line number Diff line number Diff line
@@ -338,7 +338,7 @@ AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method) {
    return 0;
}

AP_DECLARE(void) ap_register_hooks(module *m)
AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p)
{
    if(m->register_hooks)
    {
@@ -348,13 +348,13 @@ AP_DECLARE(void) ap_register_hooks(module *m)
	    ap_debug_module_hooks=1;
	}
	ap_current_hooking_module=m->name;
	m->register_hooks();
	m->register_hooks(p);
    }
}

/* One-time setup for precompiled modules --- NOT to be done on restart */

AP_DECLARE(void) ap_add_module(module *m)
AP_DECLARE(void) ap_add_module(module *m, apr_pool_t *p)
{
    /* This could be called from an AddModule httpd.conf command,
     * after the file has been linked and the module structure within it
@@ -407,8 +407,10 @@ AP_DECLARE(void) ap_add_module(module *m)
    }
#endif /*_OSD_POSIX*/

    /* FIXME: is this the right place to call this? */
    ap_register_hooks(m);
    /*  FIXME: is this the right place to call this?
     *  It doesn't appear to be
     */
    ap_register_hooks(m, p);
}

/* 
@@ -454,14 +456,14 @@ AP_DECLARE(void) ap_remove_module(module *m)
    total_modules--;
}

AP_DECLARE(void) ap_add_loaded_module(module *mod)
AP_DECLARE(void) ap_add_loaded_module(module *mod, apr_pool_t *p)
{
    module **m;

    /* 
     *  Add module pointer to top of chained module list 
     */
    ap_add_module(mod);
    ap_add_module(mod, p);

    /* 
     *  And module pointer to list of loaded modules 
@@ -537,7 +539,7 @@ AP_DECLARE(void) ap_setup_prelinked_modules(process_rec *process)
     *   Initialize chain of linked (=activate) modules
     */
    for (m = ap_prelinked_modules; *m != NULL; m++)
        ap_add_module(*m);
        ap_add_module(*m, process->pconf);

    ap_sort_hooks();
}
@@ -559,7 +561,7 @@ AP_DECLARE(module *) ap_find_linked_module(const char *name)
}

/* Add a named module.  Returns 1 if module found, 0 otherwise.  */
AP_DECLARE(int) ap_add_named_module(const char *name)
AP_DECLARE(int) ap_add_named_module(const char *name, apr_pool_t *p)
{
    module *modp;
    int i = 0;
@@ -568,7 +570,7 @@ AP_DECLARE(int) ap_add_named_module(const char *name)
	if (strcmp(modp->name, name) == 0) {
	    /* Only add modules that are not already enabled.  */
	    if (modp->next == NULL) {
		ap_add_module(modp);
		ap_add_module(modp, p);
	    }
	    return 1;
	}
@@ -578,7 +580,7 @@ AP_DECLARE(int) ap_add_named_module(const char *name)
}

/* Clear the internal list of modules, in preparation for starting over. */
AP_DECLARE(void) ap_clear_module_list()
AP_DECLARE(void) ap_clear_module_list(apr_pool_t *p)
{
    module **m = &top_module;
    module **next_m;
@@ -590,7 +592,7 @@ AP_DECLARE(void) ap_clear_module_list()
    }

    /* This is required; so we add it always.  */
    ap_add_named_module("http_core.c");
    ap_add_named_module("http_core.c", p);
}

/*****************************************************************
+1 −1
Original line number Diff line number Diff line
@@ -404,7 +404,7 @@ int main(int argc, const char * const argv[])
	ap_hook_deregister_all();
	apr_clear_pool(pconf);
	for (mod = ap_prelinked_modules; *mod != NULL; mod++) {
		ap_register_hooks(*mod);
		ap_register_hooks(*mod, pconf);
	}
        /* This is a hack until we finish the code so that it only reads
         * the config file once and just operates on the tree already in