X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=loadcfg.c;h=f3a8f96910b9ca5c6cc8939bfca81f3bd1dbb125;hp=39c556668ab7df05daf5d0c7f4e0f191165b14d6;hb=0e2be80c3229e207936c707d42630914eef3caaa;hpb=2a7b6004587d0b734ab12d87f9f7805e7329a6e9 diff --git a/loadcfg.c b/loadcfg.c index 39c55666..f3a8f969 100644 --- a/loadcfg.c +++ b/loadcfg.c @@ -1,4 +1,4 @@ -const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.65 2007/07/21 11:51:36 fabiankeil Exp $"; +const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.69 2007/10/27 13:02:27 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $ @@ -35,6 +35,20 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.65 2007/07/21 11:51:36 fabiankeil * * Revisions : * $Log: loadcfg.c,v $ + * Revision 1.69 2007/10/27 13:02:27 fabiankeil + * Relocate daemon-mode-related log messages to make sure + * they aren't shown again in case of configuration reloads. + * + * Revision 1.68 2007/10/19 16:32:34 fabiankeil + * Plug memory leak introduced with my last commit. + * + * Revision 1.67 2007/10/14 14:12:41 fabiankeil + * When in daemon mode, close stderr after the configuration file has been + * parsed the first time. If logfile isn't set, stop logging. Fixes BR#897436. + * + * Revision 1.66 2007/08/05 14:02:09 fabiankeil + * #1763173 from Stefan Huehner: declare unload_configfile() static. + * * Revision 1.65 2007/07/21 11:51:36 fabiankeil * As Hal noticed, checking dispatch_cgi() as the last cruncher * looks like a bug if CGI requests are blocked unintentionally, @@ -661,6 +675,9 @@ void unload_current_config_file(void) * * Description : Load the config file and all parameters. * + * XXX: more than thousand lines long + * and thus in serious need of refactoring. + * * Parameters : None * * Returns : The configuration_spec, or NULL on error. @@ -676,6 +693,7 @@ struct configuration_spec * load_config(void) struct file_list *fs; unsigned long linenum = 0; int i; + char *logfile = NULL; if ( !check_file_changed(current_configfile, configfile, &fs)) { @@ -1291,8 +1309,14 @@ struct configuration_spec * load_config(void) * In logdir by default * *************************************************************************/ case hash_logfile : - freez(config->logfile); - config->logfile = no_daemon ? NULL : make_path(config->logdir, arg); + if (!no_daemon) + { + logfile = make_path(config->logdir, arg); + if (NULL == logfile) + { + log_error(LOG_LEVEL_FATAL, "Out of memory while creating logfile path"); + } + } continue; /* ************************************************************************* @@ -1593,13 +1617,28 @@ struct configuration_spec * load_config(void) fclose(configfp); + set_debug_level(config->debug); + + freez(config->logfile); + + if (!no_daemon) + { + if (NULL != logfile) + { + config->logfile = logfile; + init_error_log(Argv[0], config->logfile); + } + else + { + disable_logging(); + } + } + if (NULL == config->proxy_args) { log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args"); } - init_error_log(Argv[0], config->logfile, config->debug); - if (config->actions_file[0]) { add_loader(load_actions_file, config); @@ -1653,7 +1692,11 @@ struct configuration_spec * load_config(void) } if (*config->haddr == '\0') { - config->haddr = NULL; + /* + * Only the port specified. We stored it in config->hport + * and don't need its text representation anymore. + */ + freez(config->haddr); } }