[asterisk-commits] russell: branch russell/chan_refcount r82561 - /team/russell/chan_refcount/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 17 00:41:11 CDT 2007


Author: russell
Date: Mon Sep 17 00:40:22 2007
New Revision: 82561

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82561
Log:
simplify some code

Modified:
    team/russell/chan_refcount/main/channel.c

Modified: team/russell/chan_refcount/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/channel.c?view=diff&rev=82561&r1=82560&r2=82561
==============================================================================
--- team/russell/chan_refcount/main/channel.c (original)
+++ team/russell/chan_refcount/main/channel.c Mon Sep 17 00:40:22 2007
@@ -1363,29 +1363,14 @@
 
 int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
 {
-	int res = 0;
-
 	AST_LIST_INSERT_HEAD(&chan->datastores, datastore, entry);
 
-	return res;
+	return 0;
 }
 
 int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
 {
-	struct ast_datastore *datastore2 = NULL;
-	int res = -1;
-
-	/* Find our position and remove ourselves */
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->datastores, datastore2, entry) {
-		if (datastore2 == datastore) {
-			AST_LIST_REMOVE_CURRENT(&chan->datastores, entry);
-			res = 0;
-			break;
-		}
-	}
-	AST_LIST_TRAVERSE_SAFE_END
-
-	return res;
+	return AST_LIST_REMOVE(&chan->datastores, datastore, entry) ? 0 : -1;
 }
 
 struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
@@ -3475,12 +3460,7 @@
 		final_clone = clone->_bridge;
 
 	if ((final_orig != original) || (final_clone != clone)) {
-		ast_channel_lock(final_orig);
-		while (ast_channel_trylock(final_clone)) {
-			ast_channel_unlock(final_orig);
-			usleep(1);
-			ast_channel_lock(final_orig);
-		}
+		ast_channel_lock_both(final_orig, final_clone);
 		ast_channel_unlock(clone);
 		ast_channel_unlock(original);
 		original = final_orig;
@@ -3489,13 +3469,13 @@
 
 	if (original == clone) {
 		ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name);
-		ast_channel_unlock(clone);
-		ast_channel_unlock(original);
-		return -1;
+		res = -1;
+		goto return_unlock;
 	}
 
 	ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
 		clone->name, original->name);
+
 	if (original->masq) {
 		ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
 			original->masq->name, original->name);
@@ -3511,6 +3491,7 @@
 		res = 0;
 	}
 
+return_unlock:
 	ast_channel_unlock(clone);
 	ast_channel_unlock(original);
 




More information about the asterisk-commits mailing list