[asterisk-commits] bmd: branch group/newcdr r189952 - /team/group/newcdr/channels/chan_iax2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 22 11:59:10 CDT 2009


Author: bmd
Date: Wed Apr 22 11:59:07 2009
New Revision: 189952

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=189952
Log:
make this compile.  Also address some concerns after russell looked at it wrt iaxs[fr->callno] disappearing during deadlock avoidance.

Modified:
    team/group/newcdr/channels/chan_iax2.c

Modified: team/group/newcdr/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/channels/chan_iax2.c?view=diff&rev=189952&r1=189951&r2=189952
==============================================================================
--- team/group/newcdr/channels/chan_iax2.c (original)
+++ team/group/newcdr/channels/chan_iax2.c Wed Apr 22 11:59:07 2009
@@ -8328,13 +8328,15 @@
 static void set_hangup_source_and_cause(int callno, unsigned char causecode)
 {
 	int locked = 0;
+	struct ast_channel *owner=NULL;
 
 	do {
-		if (ast_mutex_trylock(&iaxs[callno]->owner->lock)) {
+		if (ast_channel_trylock(iaxs[callno]->owner)) {
 			DEADLOCK_AVOIDANCE(&iaxsl[callno]);
 		}
 		else {
 			locked = 1;
+			owner = iaxs[callno]->owner;
 		}
 	}
 	while (!locked && iaxs[callno] && iaxs[callno]->owner);
@@ -8344,11 +8346,10 @@
 			iaxs[callno]->owner->hangupcause = causecode;
 		}
 		ast_set_hangupsource(iaxs[callno]->owner, iaxs[callno]->owner->name, 0);
-		ast_mutex_unlock(&iaxs[callno]->owner->lock);
-	}
-	else if (locked) {
-		ast_debug(1, "Neat, somebody took away the channel at a magical time but i found it!\n");
-		ast_mutex_unlock(&iaxsl[callno]);
+		ast_channel_unlock(owner);
+	}
+	if (locked) {
+		ast_channel_unlock(owner);
 	}
 }
 
@@ -9121,6 +9122,10 @@
 				/* Set hangup cause according to remote and hangupsource */
 				if (iaxs[fr->callno]->owner) {
 					set_hangup_source_and_cause(fr->callno, ies.causecode);
+					if (!iaxs[fr->callno]) {
+						ast_mutex_unlock(&iaxsl[fr->callno]);
+						return 1;
+					}
 				}
 
 				/* Send ack immediately, before we destroy */
@@ -9131,6 +9136,10 @@
 				/* Set hangup cause according to remote and hangup source */
 				if (iaxs[fr->callno]->owner) {
 					set_hangup_source_and_cause(fr->callno, ies.causecode);
+					if (!iaxs[fr->callno]) {
+						ast_mutex_unlock(&iaxsl[fr->callno]);
+						return 1;
+					}
 				}
 
 				if (!ast_test_flag(iaxs[fr->callno], IAX_PROVISION)) {




More information about the asterisk-commits mailing list