[asterisk-addons-commits] tilghman: branch 1.6.0 r720 - in /branches/1.6.0: ./ cdr/cdr_addon_mysql.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Thu Jan 8 15:58:17 CST 2009


Author: tilghman
Date: Thu Jan  8 15:58:17 2009
New Revision: 720

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=720
Log:
Merged revisions 719 via svnmerge from 
https://origsvn.digium.com/svn/asterisk-addons/trunk

........
  r719 | tilghman | 2009-01-08 15:55:12 -0600 (Thu, 08 Jan 2009) | 2 lines
  
  Prevent a possible race between a reload event and logging a CDR
Closes issue #14002
........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/cdr/cdr_addon_mysql.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
--- trunk-merged (original)
+++ trunk-merged Thu Jan  8 15:58:17 2009
@@ -1,1 +1,1 @@
-/trunk:540-559,575,579,583,586,588,590,592,594,603,607,612,615,617,627,647,653,659,662,707,715
+/trunk:540-559,575,579,583,586,588,590,592,594,603,607,612,615,617,627,647,653,659,662,707,715,719

Modified: branches/1.6.0/cdr/cdr_addon_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/branches/1.6.0/cdr/cdr_addon_mysql.c?view=diff&rev=720&r1=719&r2=720
==============================================================================
--- branches/1.6.0/cdr/cdr_addon_mysql.c (original)
+++ branches/1.6.0/cdr/cdr_addon_mysql.c Thu Jan  8 15:58:17 2009
@@ -337,7 +337,7 @@
 	return 0;
 }
 
-static int my_unload_module(void)
+static int my_unload_module(int reload)
 { 
 	struct unload_string *us;
 	struct column *entry;
@@ -357,11 +357,15 @@
 	}
 	AST_LIST_UNLOCK(&unload_strings);
 
-	AST_RWLIST_WRLOCK(&columns);
+	if (!reload) {
+		AST_RWLIST_WRLOCK(&columns);
+	}
 	while ((entry = AST_RWLIST_REMOVE_HEAD(&columns, list))) {
 		ast_free(entry);
 	}
-	AST_RWLIST_UNLOCK(&columns);
+	if (!reload) {
+		AST_RWLIST_UNLOCK(&columns);
+	}
 
 	dbport = 0;
 	ast_cdr_unregister(name);
@@ -430,12 +434,17 @@
 	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
 		return AST_MODULE_LOAD_SUCCESS;
 
-	if (reload)
-		my_unload_module();
+	if (reload) {
+		AST_RWLIST_WRLOCK(&columns);
+		my_unload_module(1);
+	}
 
 	var = ast_variable_browse(cfg, "global");
 	if (!var) {
 		/* nothing configured */
+		if (reload) {
+			AST_RWLIST_UNLOCK(&columns);
+		}
 		return AST_MODULE_LOAD_SUCCESS;
 	}
 
@@ -464,10 +473,16 @@
 	}
 
 	if (res < 0)
+		if (reload) {
+			AST_RWLIST_UNLOCK(&columns);
+		}
 		return AST_MODULE_LOAD_FAILURE;
 
 	/* Check for any aliases */
-	AST_RWLIST_WRLOCK(&columns);
+	if (!reload) {
+		/* Lock, if not already */
+		AST_RWLIST_WRLOCK(&columns);
+	}
 	while ((entry = AST_LIST_REMOVE_HEAD(&columns, list))) {
 		ast_free(entry);
 	}
@@ -599,7 +614,7 @@
 
 static int unload_module(void)
 {
-	return my_unload_module();
+	return my_unload_module(0);
 }
 
 static int reload(void)




More information about the asterisk-addons-commits mailing list