Skip to content
Snippets Groups Projects
Commit 2fc1f89c authored by Tilghman Lesher's avatar Tilghman Lesher
Browse files

Fix cdr_manager, such that if the config file is created past load, it'll

start logging (and conversely, if the config file is destroyed or deactivated,
the logging is disabled).  Reported by Juggie via IRC, fix by me.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@83466 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 9f64905d
No related branches found
No related tags found
No related merge requests found
...@@ -52,12 +52,15 @@ static char *name = "cdr_manager"; ...@@ -52,12 +52,15 @@ static char *name = "cdr_manager";
static int enablecdr = 0; static int enablecdr = 0;
struct ast_str *customfields; struct ast_str *customfields;
static int manager_log(struct ast_cdr *cdr);
static int load_config(int reload) static int load_config(int reload)
{ {
char *cat = NULL; char *cat = NULL;
struct ast_config *cfg; struct ast_config *cfg;
struct ast_variable *v; struct ast_variable *v;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
int newenablecdr = 0;
cfg = ast_config_load(CONF_FILE, config_flags); cfg = ast_config_load(CONF_FILE, config_flags);
if (cfg == CONFIG_STATUS_FILEUNCHANGED) if (cfg == CONFIG_STATUS_FILEUNCHANGED)
...@@ -71,6 +74,8 @@ static int load_config(int reload) ...@@ -71,6 +74,8 @@ static int load_config(int reload)
if (!cfg) { if (!cfg) {
/* Standard configuration */ /* Standard configuration */
ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n"); ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n");
if (enablecdr)
ast_cdr_unregister(name);
enablecdr = 0; enablecdr = 0;
return 0; return 0;
} }
...@@ -79,9 +84,8 @@ static int load_config(int reload) ...@@ -79,9 +84,8 @@ static int load_config(int reload)
if (!strcasecmp(cat, "general")) { if (!strcasecmp(cat, "general")) {
v = ast_variable_browse(cfg, cat); v = ast_variable_browse(cfg, cat);
while (v) { while (v) {
if (!strcasecmp(v->name, "enabled")) { if (!strcasecmp(v->name, "enabled"))
enablecdr = ast_true(v->value); newenablecdr = ast_true(v->value);
}
v = v->next; v = v->next;
} }
...@@ -105,6 +109,12 @@ static int load_config(int reload) ...@@ -105,6 +109,12 @@ static int load_config(int reload)
} }
ast_config_destroy(cfg); ast_config_destroy(cfg);
if (enablecdr && !newenablecdr)
ast_cdr_unregister(name);
else if (!enablecdr && newenablecdr)
ast_cdr_register(name, "Asterisk Manager Interface CDR Backend", manager_log);
return 1; return 1;
} }
...@@ -178,18 +188,11 @@ static int unload_module(void) ...@@ -178,18 +188,11 @@ static int unload_module(void)
static int load_module(void) static int load_module(void)
{ {
int res;
/* Configuration file */ /* Configuration file */
if (!load_config(0)) if (!load_config(0))
return AST_MODULE_LOAD_DECLINE; return AST_MODULE_LOAD_DECLINE;
res = ast_cdr_register(name, "Asterisk Manager Interface CDR Backend", manager_log); return AST_MODULE_LOAD_SUCCESS;
if (res) {
ast_log(LOG_ERROR, "Unable to register Asterisk Call Manager CDR handling\n");
}
return res;
} }
static int reload(void) static int reload(void)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment