[asterisk-commits] russell: branch 1.4 r211112 - /branches/1.4/apps/app_chanspy.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 7 15:11:35 CDT 2009


Author: russell
Date: Fri Aug  7 15:11:31 2009
New Revision: 211112

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=211112
Log:
Resolve a deadlock involving app_chanspy and masquerades.

(ABE-1936)

Modified:
    branches/1.4/apps/app_chanspy.c

Modified: branches/1.4/apps/app_chanspy.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.4/apps/app_chanspy.c?view=diff&rev=211112&r1=211111&r2=211112
==============================================================================
--- branches/1.4/apps/app_chanspy.c (original)
+++ branches/1.4/apps/app_chanspy.c Fri Aug  7 15:11:31 2009
@@ -422,17 +422,20 @@
 
 static struct chanspy_ds *chanspy_ds_free(struct chanspy_ds *chanspy_ds)
 {
-	if (!chanspy_ds)
+	struct ast_channel *chan;
+
+	if (!chanspy_ds) {
 		return NULL;
+	}
 
 	ast_mutex_lock(&chanspy_ds->lock);
-	if (chanspy_ds->chan) {
+	while ((chan = chanspy_ds->chan)) {
 		struct ast_datastore *datastore;
-		struct ast_channel *chan;
-
-		chan = chanspy_ds->chan;
-
-		ast_channel_lock(chan);
+
+		if (ast_channel_trylock(chan)) {
+			DEADLOCK_AVOIDANCE(&chanspy_ds->lock);
+			continue;
+		}
 		if ((datastore = ast_channel_datastore_find(chan, &chanspy_ds_info, chanspy_ds->unique_id))) {
 			ast_channel_datastore_remove(chan, datastore);
 			/* chanspy_ds->chan is NULL after this call */
@@ -441,6 +444,7 @@
 			ast_channel_datastore_free(datastore);
 		}
 		ast_channel_unlock(chan);
+		break;
 	}
 	ast_mutex_unlock(&chanspy_ds->lock);
 




More information about the asterisk-commits mailing list