[asterisk-commits] russell: branch 1.6.0 r202263 - in /branches/1.6.0: ./ cdr/cdr_manager.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jun 21 11:14:16 CDT 2009
Author: russell
Date: Sun Jun 21 11:14:05 2009
New Revision: 202263
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=202263
Log:
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.
........
Modified:
branches/1.6.0/ (props changed)
branches/1.6.0/cdr/cdr_manager.c
Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.0/cdr/cdr_manager.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.0/cdr/cdr_manager.c?view=diff&rev=202263&r1=202262&r2=202263
==============================================================================
--- branches/1.6.0/cdr/cdr_manager.c (original)
+++ branches/1.6.0/cdr/cdr_manager.c Sun Jun 21 11:14:05 2009
@@ -46,7 +46,9 @@
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);
@@ -62,11 +64,6 @@
if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
}
-
- if (reload && customfields) {
- ast_free(customfields);
- }
- customfields = NULL;
if (!cfg) {
/* Standard configuration */
@@ -77,6 +74,15 @@
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);
@@ -105,6 +111,10 @@
}
}
+ if (reload) {
+ ast_rwlock_unlock(&customfields_lock);
+ }
+
ast_config_destroy(cfg);
if (enablecdr && !newenablecdr)
@@ -139,13 +149,14 @@
ast_localtime(&cdr->end, &timeresult, NULL);
ast_strftime(strEndTime, sizeof(strEndTime), DATE_FORMAT, &timeresult);
- buf[0] = 0;
- /* Custom fields handling */
- if (customfields != NULL && customfields->used > 0) {
+ 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, customfields->str, buf, sizeof(buf) - 1);
}
+ ast_rwlock_unlock(&customfields_lock);
manager_event(EVENT_FLAG_CDR, "Cdr",
"AccountCode: %s\r\n"
More information about the asterisk-commits
mailing list