[svn-commits] mmichelson: branch group/CCSS r247735 - /team/group/CCSS/main/ccss.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Feb 18 14:55:44 CST 2010


Author: mmichelson
Date: Thu Feb 18 14:55:41 2010
New Revision: 247735

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=247735
Log:
Add some locking where it should be done.


Modified:
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=247735&r1=247734&r2=247735
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Thu Feb 18 14:55:41 2010
@@ -1547,31 +1547,45 @@
 	struct ast_cc_monitor *monitor;
 	struct extension_monitor_pvt *extension_pvt;
 	struct extension_child_dialstring *child_dialstring;
-
+	struct ast_cc_interface_tree *interface_tree;
+	int id;
+
+	ast_channel_lock(incoming);
 	if (!(cc_datastore = ast_channel_datastore_find(incoming, &dialed_cc_interfaces_info, NULL))) {
+		ast_channel_unlock(incoming);
 		return;
 	}
 
 	cc_interfaces = cc_datastore->data;
-	AST_DLLIST_TRAVERSE(cc_interfaces->interface_tree, monitor, next) {
-		if (monitor->id == cc_interfaces->dial_parent_id) {
-			ast_log(LOG_NOTICE, "Found monitor named %s\n", monitor->interface->device_name);
+	interface_tree = cc_ref(cc_interfaces->interface_tree, "Gaining reference to tree so we can unlock the channel");
+	id = cc_interfaces->dial_parent_id;
+	ast_channel_unlock(incoming);
+
+	AST_DLLIST_LOCK(interface_tree);
+	AST_DLLIST_TRAVERSE(interface_tree, monitor, next) {
+		if (monitor->id == id) {
 			break;
 		}
 	}
 
 	if (!monitor) {
+		AST_DLLIST_UNLOCK(interface_tree);
+		cc_unref(interface_tree, "Done with interface tree");
 		return;
 	}
 
 	extension_pvt = monitor->private_data;
 	if (!(child_dialstring = ast_calloc(1, sizeof(*child_dialstring)))) {
+		AST_DLLIST_UNLOCK(interface_tree);
+		cc_unref(interface_tree, "Done with interface tree");
 		return;
 	}
 	ast_copy_string(child_dialstring->original_dialstring, dialstring, sizeof(child_dialstring->original_dialstring));
 	ast_copy_string(child_dialstring->device_name, device_name, sizeof(child_dialstring->device_name));
 	child_dialstring->is_valid = 1;
 	AST_LIST_INSERT_TAIL(&extension_pvt->child_dialstrings, child_dialstring, next);
+	AST_DLLIST_UNLOCK(interface_tree);
+	cc_unref(interface_tree, "Done with interface tree");
 }
 
 static void cc_extension_monitor_change_is_valid(struct cc_core_instance *core_instance, unsigned int parent_id, const char * const device_name, int is_valid)




More information about the svn-commits mailing list