[asterisk-commits] mnicholson: branch 1.6.0 r220940 - /branches/1.6.0/apps/app_chanspy.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 29 15:25:48 CDT 2009


Author: mnicholson
Date: Tue Sep 29 15:25:43 2009
New Revision: 220940

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=220940
Log:
Avoid a deadlock in chanspy, just in case the spyee is masqueraded and chanspy_ds_chan_fixup() is called with the channel locked.
  
(closes issue #15965)
Reported by: atis
Patches:
      chanspy-deadlock-fix1.diff uploaded by mnicholson (license 96)
Tested by: atis

Modified:
    branches/1.6.0/apps/app_chanspy.c

Modified: branches/1.6.0/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/apps/app_chanspy.c?view=diff&rev=220940&r1=220939&r2=220940
==============================================================================
--- branches/1.6.0/apps/app_chanspy.c (original)
+++ branches/1.6.0/apps/app_chanspy.c Tue Sep 29 15:25:43 2009
@@ -271,9 +271,10 @@
 	ast_channel_unlock(chan);
 
 	ast_mutex_lock(&spyee_chanspy_ds->lock);
-	if (spyee_chanspy_ds->chan) {
-		spyee = spyee_chanspy_ds->chan;
-		ast_channel_lock(spyee);
+	while ((spyee = spyee_chanspy_ds->chan) && ast_channel_trylock(spyee)) {
+		/* avoid a deadlock here, just in case spyee is masqueraded and
+		 * chanspy_ds_chan_fixup() is called with the channel locked */
+		DEADLOCK_AVOIDANCE(&spyee_chanspy_ds->lock);
 	}
 	ast_mutex_unlock(&spyee_chanspy_ds->lock);
 




More information about the asterisk-commits mailing list