httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/main http_config.c http_core.c http_main.c
Date Sat, 03 Jun 2000 16:27:04 GMT
rbb         00/06/03 09:27:04

  Modified:    src      CHANGES
               src/include http_config.h
               src/main http_config.c http_core.c http_main.c
  Log:
  Modify the config order so that we read the config, process all EXEC_ON_READ
  directives at the same time, run pre_config hook for all modules, and
  then walk the tree.  This allows all modules to have a pre_config hook and
  know that it will be called at a reasonable time.  I also made "Include"
  an EXEC_ON_READ directive so that it is included in the tree properly.
  This was required after the other changes that were made.
  
  Revision  Changes    Path
  1.130     +4 -0      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.129
  retrieving revision 1.130
  diff -u -r1.129 -r1.130
  --- CHANGES	2000/06/03 14:31:35	1.129
  +++ CHANGES	2000/06/03 16:27:02	1.130
  @@ -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] 
   
     *) mod_cgi: Make ScriptLog directive work again.  [Jeff Trawick]
   
  
  
  
  1.29      +6 -2      apache-2.0/src/include/http_config.h
  
  Index: http_config.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/http_config.h,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- http_config.h	2000/06/02 15:33:14	1.28
  +++ http_config.h	2000/06/03 16:27:03	1.29
  @@ -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);
  +void 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... */
   
  
  
  
  1.58      +45 -17    apache-2.0/src/main/http_config.c
  
  Index: http_config.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_config.c,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- http_config.c	2000/06/02 15:33:15	1.57
  +++ http_config.c	2000/06/03 16:27:03	1.58
  @@ -1052,12 +1052,16 @@
   					 ap_pool_t *p, ap_pool_t *temp_pool,
   					 ap_directive_t **conftree)
   {
  -    ap_directive_t *current = NULL;
  +    ap_directive_t *current = *conftree;
       ap_directive_t *curr_parent = NULL;
       char l[MAX_STRING_LEN];
       const char *errmsg;
   
  -    *conftree = NULL;
  +    if (current != NULL) {
  +        while (current->next) {
  +            current = current->next;
  +        }
  +    }
   
       while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
   
  @@ -1246,13 +1250,13 @@
       return 0;
   }
   
  -static void process_command_config(server_rec *s, ap_array_header_t *arr, ap_pool_t *p,
  -				    ap_pool_t *ptemp)
  +static void 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;
  @@ -1267,9 +1271,7 @@
   			      &arr_parms, NULL,
   			      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);
  +    errmsg = ap_build_config(&parms, p, ptemp, conftree);
       if (errmsg) {
           ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
                        "Syntax error in -C/-c directive:\n%s", errmsg);
  @@ -1279,11 +1281,12 @@
       ap_cfg_closefile(parms.config_file);
   }
   
  -void ap_process_resource_config(server_rec *s, const char *fname, ap_pool_t *p, ap_pool_t
*ptemp)
  +void 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;
   
  @@ -1312,9 +1315,8 @@
       }
   
       parms.config_file = cfp;
  -    errmsg = ap_build_config(&parms, p, ptemp, &conftree);
  -    if (errmsg == NULL)
  -	errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
  +
  +    errmsg = ap_build_config(&parms, p, ptemp, conftree);
   
       if (errmsg != NULL) {
   	ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
  @@ -1329,6 +1331,29 @@
       ap_cfg_closefile(cfp);
   }
   
  +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);
  +	ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
  +                     "%s", errmsg);
  +        exit(1);
  +    }
  +}
   
   int ap_parse_htaccess(void **result, request_rec *r, int override,
   		   const char *d, const char *access_name)
  @@ -1547,7 +1572,8 @@
   
   
   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);
  @@ -1556,11 +1582,13 @@
   
       /* All server-wide config files now have the SAME syntax... */
   
  -    process_command_config(s, ap_server_pre_read_config, p, ptemp);
  +    process_command_config(s, ap_server_pre_read_config, conftree,
  +                                      p, ptemp);
   
  -    ap_process_resource_config(s, confname, p, ptemp);
  +    ap_process_resource_config(s, confname, conftree, p, ptemp);
   
  -    process_command_config(s, ap_server_post_read_config, p, ptemp);
  +    process_command_config(s, ap_server_post_read_config, conftree,
  +                                      p, ptemp);
   
       fixup_virtual_hosts(p, s);
       ap_fini_vhost_config(p, s);
  
  
  
  1.64      +6 -3      apache-2.0/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- http_core.c	2000/06/02 13:38:04	1.63
  +++ http_core.c	2000/06/03 16:27:03	1.64
  @@ -1924,11 +1924,14 @@
   }
   
   
  -static const char *include_config (cmd_parms *cmd, void *dummy, char *name)
  +static const char *include_config (cmd_parms *cmd, void **dummy, char *name)
   {
  +    ap_directive_t *conftree = NULL;
  +
       ap_process_resource_config(cmd->server,
   	ap_server_root_relative(cmd->pool, name),
  -	cmd->pool, cmd->temp_pool);
  +                               	 &conftree, cmd->pool, cmd->temp_pool);
  +    *(ap_directive_t **)dummy = conftree;
       return NULL;
   }
   
  @@ -2269,7 +2272,7 @@
   { "ClearModuleList", clear_module_list_command, NULL, RSRC_CONF | EXEC_ON_READ,
     NO_ARGS, NULL },
   /* TODO: ListenBacklog in MPM */
  -{ "Include", include_config, NULL, (RSRC_CONF | ACCESS_CONF), TAKE1,
  +{ "Include", include_config, NULL, (RSRC_CONF | ACCESS_CONF | EXEC_ON_READ), TAKE1,
     "Name of the config file to be included" },
   { "LogLevel", set_loglevel, NULL, RSRC_CONF, TAKE1,
     "Level of verbosity in error logging" },
  
  
  
  1.54      +10 -2     apache-2.0/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_main.c,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- http_main.c	2000/05/31 22:06:33	1.53
  +++ http_main.c	2000/06/03 16:27:03	1.54
  @@ -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);
  @@ -396,10 +398,16 @@
   	for (mod = ap_prelinked_modules; *mod != NULL; mod++) {
   		ap_register_hooks(*mod);
   	}
  +        /* 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
  +         * memory.  rbb
  +         */
  +        conftree = NULL;
   	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);
  
  
  

Mime
View raw message