[svn-commits] russell: branch 1.6.1 r202264 - in /branches/1.6.1: ./ cdr/cdr_manager.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Sun Jun 21 11:16:00 CDT 2009
Author: russell
Date: Sun Jun 21 11:15:49 2009
New Revision: 202264
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=202264
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.1/ (props changed)
branches/1.6.1/cdr/cdr_manager.c
Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.1/cdr/cdr_manager.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/cdr/cdr_manager.c?view=diff&rev=202264&r1=202263&r2=202264
==============================================================================
--- branches/1.6.1/cdr/cdr_manager.c (original)
+++ branches/1.6.1/cdr/cdr_manager.c Sun Jun 21 11:15:49 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 */
@@ -75,6 +72,15 @@
ast_cdr_unregister(name);
enablecdr = 0;
return -1;
+ }
+
+ if (reload) {
+ ast_rwlock_wrlock(&customfields_lock);
+ }
+
+ if (reload && customfields) {
+ ast_free(customfields);
+ customfields = NULL;
}
while ( (cat = ast_category_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 svn-commits
mailing list