diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-06-21 16:16:42 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-06-21 16:16:42 +0000 |
commit | 2d17a8f3e669acffee5af48f9ef9e5ed2a09afbc (patch) | |
tree | 8bdf11ee4120b01b84b2f8db0382ce1d1bbceada /cdr | |
parent | f184affffdc2610beffd9ce53ace47a17afb6c07 (diff) |
Merged revisions 202262 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r202262 | russell | 2009-06-21 11:11:48 -0500 (Sun, 21 Jun 2009) | 2 lines
Fix possibility of crashiness during reload in custom fields handling.
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@202265 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr')
-rw-r--r-- | cdr/cdr_manager.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c index 7859b58e6..b711fc2b0 100644 --- a/cdr/cdr_manager.c +++ b/cdr/cdr_manager.c @@ -46,7 +46,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static char *name = "cdr_manager"; static int enablecdr = 0; -struct ast_str *customfields; + +static struct ast_str *customfields; +AST_RWLOCK_DEFINE_STATIC(customfields_lock); static int manager_log(struct ast_cdr *cdr); @@ -68,11 +70,6 @@ static int load_config(int reload) return -1; } - if (reload && customfields) { - ast_free(customfields); - } - customfields = NULL; - if (!cfg) { /* Standard configuration */ ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n"); @@ -82,6 +79,15 @@ static int load_config(int reload) return -1; } + if (reload) { + ast_rwlock_wrlock(&customfields_lock); + } + + if (reload && customfields) { + ast_free(customfields); + customfields = NULL; + } + while ( (cat = ast_category_browse(cfg, cat)) ) { if (!strcasecmp(cat, "general")) { v = ast_variable_browse(cfg, cat); @@ -110,6 +116,10 @@ static int load_config(int reload) } } + if (reload) { + ast_rwlock_unlock(&customfields_lock); + } + ast_config_destroy(cfg); if (enablecdr && !newenablecdr) @@ -144,13 +154,14 @@ static int manager_log(struct ast_cdr *cdr) ast_localtime(&cdr->end, &timeresult, NULL); ast_strftime(strEndTime, sizeof(strEndTime), DATE_FORMAT, &timeresult); - buf[0] = 0; - /* Custom fields handling */ - if (customfields != NULL && ast_str_strlen(customfields)) { + buf[0] = '\0'; + ast_rwlock_rdlock(&customfields_lock); + if (customfields && ast_str_strlen(customfields)) { memset(&dummy, 0, sizeof(dummy)); dummy.cdr = cdr; pbx_substitute_variables_helper(&dummy, ast_str_buffer(customfields), buf, sizeof(buf) - 1); } + ast_rwlock_unlock(&customfields_lock); manager_event(EVENT_FLAG_CDR, "Cdr", "AccountCode: %s\r\n" |