On Monday, April 11, 2011 21:14:53 Stefan Fritsch wrote:
> I guess the optimization could be done later, after the config has 
> been parsed completely. That would waste some memory in pconf but 
> still preserve the optimization during request processing, which is 
> more important.

The enclosed patch moves the conf_vector_length adjustment to when 
ap_process_config_tree() has done its work. I think that is enough for 
mod_perl.

On Tuesday, April 12, 2011 18:24:28 William A. Rowe Jr. wrote:
> Suggestion - an EXEC_ON_READ 'DynamicModulesMax' directive, which would
> let us conf_vector_length = total_modules + dyn_modules_max; after the
> read_config, and finally lock down conf_vector_length = total_modules;
> at the end of post_config.  WDYT?

But yes, moving the adjustment to postconfig will solve the problem more 
generally. I'll see if I can conceive a patch.

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net
Index: server/config.c
===================================================================
--- server/config.c	(revision 1091323)
+++ server/config.c	(working copy)
@@ -1953,6 +1953,12 @@
     return NULL;
 }
 
+static apr_status_t reset_conf_vector_length(void *dummy)
+{
+    conf_vector_length = max_modules;
+    return APR_SUCCESS;
+}
+
 AP_DECLARE(int) ap_process_config_tree(server_rec *s,
                                        ap_directive_t *conftree,
                                        apr_pool_t *p,
@@ -1981,6 +1987,20 @@
         return HTTP_INTERNAL_SERVER_ERROR;
     }
 
+    /*
+     * We have loaded the dynamic modules. From now on we know exactly how
+     * long the config vectors need to be.
+     * 
+     * You may be tempted to move the next 3 lines to ap_read_config()
+     * just after ap_process_resource_config() to save a few bytes in pconf
+     * since at that point all the LoadModule directives have been processed.
+     * Don't do that because it breaks stuff like mod_perl that offer a
+     * way to register modules as part of their configuration.
+     */
+    conf_vector_length = total_modules;
+    apr_pool_cleanup_register(p, NULL, reset_conf_vector_length,
+                              apr_pool_cleanup_null);
+
     return OK;
 }
 
@@ -2255,12 +2275,6 @@
 }
 
 
-static apr_status_t reset_conf_vector_length(void *dummy)
-{
-    conf_vector_length = max_modules;
-    return APR_SUCCESS;
-}
-
 AP_DECLARE(server_rec*) ap_read_config(process_rec *process, apr_pool_t *ptemp,
                                        const char *filename,
                                        ap_directive_t **conftree)
@@ -2309,14 +2323,6 @@
         return NULL;
     }
 
-    /*
-     * We have loaded the dynamic modules. From now on we know exactly how
-     * long the config vectors need to be.
-     */
-    conf_vector_length = total_modules;
-    apr_pool_cleanup_register(p, NULL, reset_conf_vector_length,
-                              apr_pool_cleanup_null);
-
     error = process_command_config(s, ap_server_post_read_config, conftree,
                                    p, ptemp);
 

Reply via email to