commit 6d15fab2dc377503aa20086723b6faf41a0a0d34 Author: Nick Mathewson nickm@torproject.org Date: Mon Oct 21 11:58:53 2019 -0400
Extract log-granularity code into its own function.
This pleases practracker. --- src/app/config/config.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-)
diff --git a/src/app/config/config.c b/src/app/config/config.c index 1c04dcaf0..5f59ce32f 100644 --- a/src/app/config/config.c +++ b/src/app/config/config.c @@ -5672,22 +5672,14 @@ open_and_add_file_log(const log_severity_list_t *severity, }
/** - * Initialize the logs based on the configuration file. - */ -STATIC int -options_init_logs(const or_options_t *old_options, or_options_t *options, - int validate_only) + * Try to set our global log granularity from `options->LogGranularity`, + * adjusting it as needed so that we are an even divisor of a second, or an + * even multiple of seconds. Return 0 on success, -1 on failure. + **/ +static int +options_init_log_granularity(const or_options_t *options, + int validate_only) { - config_line_t *opt; - int ok; - smartlist_t *elts; - int run_as_daemon = -#ifdef _WIN32 - 0; -#else - options->RunAsDaemon; -#endif - if (options->LogTimeGranularity <= 0) { log_warn(LD_CONFIG, "Log time granularity '%d' has to be positive.", options->LogTimeGranularity); @@ -5717,6 +5709,29 @@ options_init_logs(const or_options_t *old_options, or_options_t *options, set_log_time_granularity(options->LogTimeGranularity); }
+ return 0; +} + +/** + * Initialize the logs based on the configuration file. + */ +STATIC int +options_init_logs(const or_options_t *old_options, or_options_t *options, + int validate_only) +{ + config_line_t *opt; + int ok; + smartlist_t *elts; + int run_as_daemon = +#ifdef _WIN32 + 0; +#else + options->RunAsDaemon; +#endif + + if (options_init_log_granularity(options, validate_only) < 0) + return -1; + ok = 1; elts = smartlist_new();