diff options
author | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-21 19:13:17 +0000 |
---|---|---|
committer | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-21 19:13:17 +0000 |
commit | dd209fe1687a85430a57f69b20caf39540a65f7f (patch) | |
tree | dfe52cd93b0bd823b3a6bf60ccf55f8bdc970659 | |
parent | 85f2ccc5bee7a1358013a274127d24b9f0b51db6 (diff) |
it was pointed out that the cdr_custom config load could get a lock, and under certain circumstances, would never release it. I also noted that the situation where more than one mapping spec was warned about, but did not ignore further mappings as it had promised. I think I have fixed both situations.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@70804 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | cdr/cdr_custom.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c index 64fddb368..dfd98388e 100644 --- a/cdr/cdr_custom.c +++ b/cdr/cdr_custom.c @@ -72,21 +72,22 @@ static int load_config(int reload) strcpy(format, ""); strcpy(master, ""); + ast_mutex_lock(&lock); if((cfg = ast_config_load("cdr_custom.conf"))) { var = ast_variable_browse(cfg, "mappings"); while(var) { - ast_mutex_lock(&lock); if (!ast_strlen_zero(var->name) && !ast_strlen_zero(var->value)) { if (strlen(var->value) > (sizeof(format) - 2)) ast_log(LOG_WARNING, "Format string too long, will be truncated, at line %d\n", var->lineno); strncpy(format, var->value, sizeof(format) - 2); strcat(format,"\n"); snprintf(master, sizeof(master),"%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name); - ast_mutex_unlock(&lock); + if (var->next) { + ast_log(LOG_NOTICE, "Sorry, only one mapping is supported at this time, mapping '%s' will be ignored at line %d.\n", var->next->name, var->next->lineno); + break; + } } else ast_log(LOG_NOTICE, "Mapping must have both filename and format at line %d\n", var->lineno); - if (var->next) - ast_log(LOG_NOTICE, "Sorry, only one mapping is supported at this time, mapping '%s' will be ignored at line %d.\n", var->next->name, var->next->lineno); var = var->next; } ast_config_destroy(cfg); @@ -97,6 +98,7 @@ static int load_config(int reload) else ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n"); } + ast_mutex_unlock(&lock); return res; } |