[Home]

Summary:ASTERISK-06434: command line options do not override config defaults
Reporter:benjk (benjk)Labels:
Date Opened:2006-02-28 02:39:25.000-0600Date Closed:2006-03-29 19:38:48.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:When asterisk starts it first processes all user supplied command line options and then read the master configuration file. If defaults for options are specified in the master configuration file, then those defaults will overried the options specified on the command line.

For example, suppose you have specifed 1 in the master configuration file as the default console verbosity level and now you start asterisk with -vvv. Would you expect the resulting verbosity to be 3 as you specified on the command line, or the default 1 as specifed in the master configuration file?

I believe this is upside down. User specified options should override defaults, not vice versa.
Comments:By: benjk (benjk) 2006-02-28 03:13:13.000-0600

A quick and dirty way to fix this would be to initialise all the option variables with -1 to indicate that they are undefined. Then ast_read_config() would simply check the value of each option and only override it if it is -1.

This could look like so ...

In file asterisk.h
----------------------------------------
/* buildtime defaults for options */
#define AST_VERBOSE 0
----------------------------------------

In file asterisk.c
----------------------------------------
#define UNDEFINED -1

int option_verbose = UNDEFINED;

/* at the bottom of ast_read_config() */

if (option_verbose == UNDEFINED) {
if (!strcasecmp(v->name, "verbose")) {
option_verbose= atoi(v->value);
else {
option_verbose= AST_VERBOSE;
}
}
----------------------------------------

In the event of a restart, none of the options will be UNDEFINED any more, so the defaults in the configuration file would take precedence then. This may be expected behaviour or it may not.

By: benjk (benjk) 2006-02-28 04:20:10.000-0600

I have looked into the restart situation a bit further now. Since asterisk saves the original command line arguments to pass to itself in case of a restart, the option variable should be reinitialised and set  to undefined (-1) before a restart is invoked. There are two places where a restart is invoked, so it would make sense to move the initialisation of option variables into a function, for example ...

static void ast_init_options(int initval) {
    option_verbose = initval;
    ...
}

then insert before any occurence of execvp() ...

ast_init_options(UNDEFINED);

this will then ensure that the original command line options will take preference over defaults in the configuration file in the event of a restart as well.

By: Matt O'Gorman (mogorman) 2006-02-28 11:15:46.000-0600

benjk please see me on irc, the behavior you describe is already how asterisk works, there should be no need for any changes.

By: Tilghman Lesher (tilghman) 2006-03-11 09:52:08.000-0600

Any updates?  //Housekeeping