[asterisk-commits] russell: branch 1.6.2 r202265 - in /branches/1.6.2: ./ cdr/cdr_manager.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jun 21 11:16:53 CDT 2009


Author: russell
Date: Sun Jun 21 11:16:42 2009
New Revision: 202265

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=202265
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.2/   (props changed)
    branches/1.6.2/cdr/cdr_manager.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.2/cdr/cdr_manager.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.2/cdr/cdr_manager.c?view=diff&rev=202265&r1=202264&r2=202265
==============================================================================
--- branches/1.6.2/cdr/cdr_manager.c (original)
+++ branches/1.6.2/cdr/cdr_manager.c Sun Jun 21 11:16:42 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);
 
@@ -67,11 +69,6 @@
 		ast_log(LOG_ERROR, "Config file '%s' could not be parsed\n", CONF_FILE);
 		return -1;
 	}
-
-	if (reload && customfields) {
-		ast_free(customfields);
-	}
-	customfields = NULL;
 
 	if (!cfg) {
 		/* Standard configuration */
@@ -80,6 +77,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)) ) {
@@ -110,6 +116,10 @@
 		}
 	}
 
+	if (reload) {
+		ast_rwlock_unlock(&customfields_lock);
+	}
+
 	ast_config_destroy(cfg);
 
 	if (enablecdr && !newenablecdr)
@@ -144,13 +154,14 @@
 	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"




More information about the asterisk-commits mailing list