mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 00:30:20 +00:00
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: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@202264 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -46,7 +46,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
static char *name = "cdr_manager";
|
static char *name = "cdr_manager";
|
||||||
|
|
||||||
static int enablecdr = 0;
|
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);
|
static int manager_log(struct ast_cdr *cdr);
|
||||||
|
|
||||||
@@ -63,11 +65,6 @@ static int load_config(int reload)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reload && customfields) {
|
|
||||||
ast_free(customfields);
|
|
||||||
}
|
|
||||||
customfields = NULL;
|
|
||||||
|
|
||||||
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");
|
||||||
@@ -77,6 +74,15 @@ static int load_config(int reload)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reload) {
|
||||||
|
ast_rwlock_wrlock(&customfields_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reload && customfields) {
|
||||||
|
ast_free(customfields);
|
||||||
|
customfields = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while ( (cat = ast_category_browse(cfg, cat)) ) {
|
while ( (cat = ast_category_browse(cfg, cat)) ) {
|
||||||
if (!strcasecmp(cat, "general")) {
|
if (!strcasecmp(cat, "general")) {
|
||||||
v = ast_variable_browse(cfg, cat);
|
v = ast_variable_browse(cfg, cat);
|
||||||
@@ -105,6 +111,10 @@ static int load_config(int reload)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reload) {
|
||||||
|
ast_rwlock_unlock(&customfields_lock);
|
||||||
|
}
|
||||||
|
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
|
|
||||||
if (enablecdr && !newenablecdr)
|
if (enablecdr && !newenablecdr)
|
||||||
@@ -139,13 +149,14 @@ static int manager_log(struct ast_cdr *cdr)
|
|||||||
ast_localtime(&cdr->end, &timeresult, NULL);
|
ast_localtime(&cdr->end, &timeresult, NULL);
|
||||||
ast_strftime(strEndTime, sizeof(strEndTime), DATE_FORMAT, &timeresult);
|
ast_strftime(strEndTime, sizeof(strEndTime), DATE_FORMAT, &timeresult);
|
||||||
|
|
||||||
buf[0] = 0;
|
buf[0] = '\0';
|
||||||
/* Custom fields handling */
|
ast_rwlock_rdlock(&customfields_lock);
|
||||||
if (customfields != NULL && customfields->used > 0) {
|
if (customfields && ast_str_strlen(customfields)) {
|
||||||
memset(&dummy, 0, sizeof(dummy));
|
memset(&dummy, 0, sizeof(dummy));
|
||||||
dummy.cdr = cdr;
|
dummy.cdr = cdr;
|
||||||
pbx_substitute_variables_helper(&dummy, customfields->str, buf, sizeof(buf) - 1);
|
pbx_substitute_variables_helper(&dummy, customfields->str, buf, sizeof(buf) - 1);
|
||||||
}
|
}
|
||||||
|
ast_rwlock_unlock(&customfields_lock);
|
||||||
|
|
||||||
manager_event(EVENT_FLAG_CDR, "Cdr",
|
manager_event(EVENT_FLAG_CDR, "Cdr",
|
||||||
"AccountCode: %s\r\n"
|
"AccountCode: %s\r\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user