[svn-commits] russell: branch group/newcdr r201983 - /team/group/newcdr/main/cel.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 19 13:32:02 CDT 2009


Author: russell
Date: Fri Jun 19 13:31:59 2009
New Revision: 201983

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=201983
Log:
Use brute force to ensure the CEL core is safe from simultaneous reload attempts

Modified:
    team/group/newcdr/main/cel.c

Modified: team/group/newcdr/main/cel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/main/cel.c?view=diff&rev=201983&r1=201982&r2=201983
==============================================================================
--- team/group/newcdr/main/cel.c (original)
+++ team/group/newcdr/main/cel.c Fri Jun 19 13:31:59 2009
@@ -140,6 +140,7 @@
 	return (eventset & (1 << (int)et));
 }
 
+AST_MUTEX_DEFINE_STATIC(reload_lock);
 
 static int do_reload(void)
 {
@@ -152,6 +153,8 @@
 	struct ast_flags config_flags = { CONFIG_FLAG_FILEUNCHANGED };
 	const char *s;
 
+	ast_mutex_lock(&reload_lock);
+
 	cel_enabled = 1;
 
 	if (appset) {
@@ -170,7 +173,7 @@
 	config = ast_config_load2("cel.conf", "cel", config_flags);
 
 	if (!config || config == CONFIG_STATUS_FILEUNCHANGED) {
-		return 0;
+		goto return_cleanup;
 	}
 
 	if ((enabled_value = ast_variable_retrieve(config, "general", "enable"))) {
@@ -313,7 +316,11 @@
 return_cleanup:
 	ast_verb(3, "CEL logging %sabled.\n", cel_enabled ? "en" : "dis");
 
-	ast_config_destroy(config);
+	ast_mutex_unlock(&reload_lock);
+
+	if (config) {
+		ast_config_destroy(config);
+	}
 
 	return res;
 }




More information about the svn-commits mailing list