httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@covalent.net
Subject New config work...
Date Fri, 02 Jun 2000 23:41:48 GMT

Okay,

This latest batch of changes to the config stuff breaks reading the config
away from actually walking the config, and moves the pre_config hook to be
between the two.  :-)  With this change, all modules can have a pre_config
hook again, and they will all be called.  The next step is to turn server
tokens back on using the pre_config hook to expand them.  :-)

Ryan

? src/build.log
? src/build.err
? src/lib/apr/rlimit
Index: src/CHANGES
===================================================================
RCS file: /home/cvs/apache-2.0/src/CHANGES,v
retrieving revision 1.128
diff -u -d -b -w -u -r1.128 CHANGES
--- src/CHANGES	2000/06/02 15:33:13	1.128
+++ src/CHANGES	2000/06/02 23:40:22
@@ -1,4 +1,8 @@
 Changes with Apache 2.0a4
+  *) Move pre_config hook call to between configuration read and config
+     tree walk.  This allows all modules to implement pre_config hooks
+     and know that they will be called at an appropriate time.
+     [Ryan Bloom] 
 
   *) Add pre-config hooks back to all modules.
      [Ryan Bloom]
Index: src/include/http_config.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/include/http_config.h,v
retrieving revision 1.28
diff -u -d -b -w -u -r1.28 http_config.h
--- src/include/http_config.h	2000/06/02 15:33:14	1.28
+++ src/include/http_config.h	2000/06/02 23:40:23
@@ -380,7 +380,7 @@
 API_EXPORT(void) ap_setup_prelinked_modules(process_rec *process);
 API_EXPORT(void) ap_show_directives(void);
 API_EXPORT(void) ap_show_modules(void);
-API_EXPORT(server_rec*) ap_read_config(process_rec *process, ap_pool_t *temp_pool, const
char *config_name);
+API_EXPORT(server_rec*) ap_read_config(process_rec *process, ap_pool_t *temp_pool, const
char *config_name, ap_directive_t **conftree);
 API_EXPORT(void) ap_pre_config_hook(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp,
server_rec *s);
 API_EXPORT(void) ap_post_config_hook(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp,
server_rec *s);
 API_EXPORT(void) ap_run_rewrite_args(process_rec *process);
@@ -403,7 +403,11 @@
 
 CORE_EXPORT(const char *) ap_init_virtual_host(ap_pool_t *p, const char *hostname,
 				server_rec *main_server, server_rec **);
-void ap_process_resource_config(server_rec *s, const char *fname, ap_pool_t *p, ap_pool_t
*ptemp);
+ap_directive_t *ap_process_resource_config(server_rec *s, const char *fname, 
+                     ap_directive_t *conftree, ap_pool_t *p, ap_pool_t *ptemp);
+void ap_process_config_tree(server_rec *s, ap_directive_t *conftree,
+                            ap_pool_t *p, ap_pool_t *ptemp);
+
 
 /* For individual MPMs... */
 
Index: src/main/http_config.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_config.c,v
retrieving revision 1.57
diff -u -d -b -w -u -r1.57 http_config.c
--- src/main/http_config.c	2000/06/02 15:33:15	1.57
+++ src/main/http_config.c	2000/06/02 23:40:28
@@ -1057,8 +1057,6 @@
     char l[MAX_STRING_LEN];
     const char *errmsg;
 
-    *conftree = NULL;
-
     while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
 
 	errmsg = ap_build_config_sub(p, temp_pool, l, parms,
@@ -1246,13 +1244,15 @@
     return 0;
 }
 
-static void process_command_config(server_rec *s, ap_array_header_t *arr, ap_pool_t *p,
+static ap_directive_t *process_command_config(server_rec *s, 
+                                              ap_array_header_t *arr, 
+                                              ap_directive_t *conftree,
+                                              ap_pool_t *p,
 				    ap_pool_t *ptemp)
 {
     const char *errmsg;
     cmd_parms parms;
     arr_elts_param_t arr_parms;
-    ap_directive_t *conftree;
 
     arr_parms.curr_idx = 0;
     arr_parms.array = arr;
@@ -1268,8 +1268,6 @@
 			      arr_elts_getstr, arr_elts_close);
 
     errmsg = ap_build_config(&parms, p, ptemp, &conftree);
-    if (errmsg == NULL)
-	errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
     if (errmsg) {
         ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
                      "Syntax error in -C/-c directive:\n%s", errmsg);
@@ -1277,13 +1275,15 @@
     }
 
     ap_cfg_closefile(parms.config_file);
+    return conftree;
 }
 
-void ap_process_resource_config(server_rec *s, const char *fname, ap_pool_t *p, ap_pool_t
*ptemp)
+ap_directive_t *ap_process_resource_config(server_rec *s, 
+                                const char *fname, ap_directive_t *conftree, 
+                                ap_pool_t *p, ap_pool_t *ptemp)
 {
     cmd_parms parms;
     ap_finfo_t finfo;
-    ap_directive_t *conftree;
     const char *errmsg;
     configfile_t *cfp;
 
@@ -1293,7 +1293,7 @@
     if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) &&
        !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
 	if (ap_stat(&finfo, fname, p) != APR_SUCCESS)     
-	    return;
+	    return NULL;
     }
 
     /* GCC's initialization extensions are soooo nice here... */
@@ -1313,8 +1313,6 @@
 
     parms.config_file = cfp;
     errmsg = ap_build_config(&parms, p, ptemp, &conftree);
-    if (errmsg == NULL)
-	errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
 
     if (errmsg != NULL) {
 	ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
@@ -1327,9 +1325,31 @@
     }
 
     ap_cfg_closefile(cfp);
+    return conftree;
 }
 
+void ap_process_config_tree(server_rec *s, ap_directive_t *conftree,
+                            ap_pool_t *p, ap_pool_t *ptemp)
+{
+    const char *errmsg;
+    cmd_parms parms;
+
+    parms = default_parms;
+    parms.pool = p;
+    parms.temp_pool = ptemp;
+    parms.server = s;
+    parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
 
+    errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
+    if (errmsg) {
+        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+                     "Syntax error on line %d of %s:",
+                     parms.err_directive->line_num,
+                     parms.err_directive->filename);
+        exit(1);
+    }
+}
+
 int ap_parse_htaccess(void **result, request_rec *r, int override,
 		   const char *d, const char *access_name)
 {
@@ -1547,20 +1567,24 @@
 
 
 API_EXPORT(server_rec*) ap_read_config(process_rec *process, ap_pool_t *ptemp,
-                                       const char *confname)
+                                       const char *confname, 
+                                       ap_directive_t **conftree)
 {
     ap_pool_t *p = process->pconf;
     server_rec *s = init_server_config(process, p);
+    (*conftree) = NULL;
 
     init_config_globals(p);
 
     /* All server-wide config files now have the SAME syntax... */
 
-    process_command_config(s, ap_server_pre_read_config, p, ptemp);
+    *conftree = process_command_config(s, ap_server_pre_read_config, *conftree,
+                                      p, ptemp);
 
-    ap_process_resource_config(s, confname, p, ptemp);
+    *conftree = ap_process_resource_config(s, confname, *conftree, p, ptemp);
 
-    process_command_config(s, ap_server_post_read_config, p, ptemp);
+    *conftree = process_command_config(s, ap_server_post_read_config, *conftree,
+                                      p, ptemp);
 
     fixup_virtual_hosts(p, s);
     ap_fini_vhost_config(p, s);
Index: src/main/http_core.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v
retrieving revision 1.63
diff -u -d -b -w -u -r1.63 http_core.c
--- src/main/http_core.c	2000/06/02 13:38:04	1.63
+++ src/main/http_core.c	2000/06/02 23:40:28
@@ -1926,9 +1926,11 @@
 
 static const char *include_config (cmd_parms *cmd, void *dummy, char *name)
 {
-    ap_process_resource_config(cmd->server,
+    ap_directive_t *conftree = NULL;
+
+    conftree = ap_process_resource_config(cmd->server,
 	ap_server_root_relative(cmd->pool, name),
-	cmd->pool, cmd->temp_pool);
+                               	 conftree, cmd->pool, cmd->temp_pool);
     return NULL;
 }
 
Index: src/main/http_main.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_main.c,v
retrieving revision 1.53
diff -u -d -b -w -u -r1.53 http_main.c
--- src/main/http_main.c	2000/05/31 22:06:33	1.53
+++ src/main/http_main.c	2000/06/02 23:40:28
@@ -296,6 +296,7 @@
     ap_pool_t *ptemp; /* Pool for temporary config stuff, reset often */
     ap_pool_t *pcommands; /* Pool for -D, -C and -c switches */
     module **mod;
+    ap_directive_t *conftree = NULL;
 
 #ifndef WIN32 /* done in main_win32.c */
     ap_initialize();
@@ -379,8 +380,9 @@
        for example, to settle down. */
 
     ap_server_root = def_server_root;
+    server_conf = ap_read_config(process, ptemp, confname, &conftree);
     ap_run_pre_config(pconf, plog, ptemp);
-    server_conf = ap_read_config(process, ptemp, confname);
+    ap_process_config_tree(server_conf, conftree, process->pconf, ptemp); 
     if (configtestonly) {
 	ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Syntax OK\n");
 	destroy_and_exit_process(process, 0);
@@ -398,8 +400,9 @@
 	}
 	ap_create_pool(&ptemp, pconf);
 	ap_server_root = def_server_root;
+        server_conf = ap_read_config(process, ptemp, confname, &conftree);
 	ap_run_pre_config(pconf, plog, ptemp);
-	server_conf = ap_read_config(process, ptemp, confname);
+        ap_process_config_tree(server_conf, conftree, process->pconf, ptemp); 
 	ap_clear_pool(plog);
 	ap_run_open_logs(pconf, plog, ptemp, server_conf);
 	ap_post_config_hook(pconf, plog, ptemp, server_conf);

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------



Mime
View raw message