[asterisk-commits] mmichelson: branch group/issue8824 r183332 - /team/group/issue8824/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 19 14:19:30 CDT 2009


Author: mmichelson
Date: Thu Mar 19 14:19:26 2009
New Revision: 183332

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183332
Log:
Some progress towards addressing Russell's comments.

Please don't look at the diff of chan_local. It is embarrassing.


Modified:
    team/group/issue8824/channels/chan_local.c
    team/group/issue8824/channels/chan_sip.c

Modified: team/group/issue8824/channels/chan_local.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue8824/channels/chan_local.c?view=diff&rev=183332&r1=183331&r2=183332
==============================================================================
--- team/group/issue8824/channels/chan_local.c (original)
+++ team/group/issue8824/channels/chan_local.c Thu Mar 19 14:19:26 2009
@@ -536,8 +536,24 @@
 
 	if (!p)
 		return -1;
-	
-	ast_mutex_lock(&p->lock);
+
+	/* If you value your sanity, please don't look at this code */
+start_over:
+	while (ast_channel_trylock(p->chan)) {
+		ast_channel_unlock(p->owner);
+		usleep(1);
+		ast_channel_lock(p->owner);
+	}
+
+	/* p->owner and p->chan are locked now. Let's get p locked */
+	if (ast_mutex_trylock(&p->lock)) {
+		/* @#$&$@ */
+		ast_channel_unlock(p->chan);
+		ast_channel_unlock(p->owner);
+		usleep(1);
+		ast_channel_lock(p->owner);
+		goto start_over;
+	}
 
 	/*
 	 * Note that cid_num and cid_name aren't passed in the ast_channel_alloc
@@ -594,6 +610,7 @@
 		ast_set_flag(p, LOCAL_LAUNCHED_PBX);
 
 	ast_mutex_unlock(&p->lock);
+	ast_channel_unlock(p->chan);
 	return res;
 }
 

Modified: team/group/issue8824/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue8824/channels/chan_sip.c?view=diff&rev=183332&r1=183331&r2=183332
==============================================================================
--- team/group/issue8824/channels/chan_sip.c (original)
+++ team/group/issue8824/channels/chan_sip.c Thu Mar 19 14:19:26 2009
@@ -5096,7 +5096,9 @@
 		p->t38.jointcapability = p->t38.capability;
 		ast_debug(2, "Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
 
+		sip_pvt_lock(p);
 		xmitres = transmit_invite(p, SIP_INVITE, 1, 2);
+		sip_pvt_unlock(p);
 		if (xmitres == XMIT_ERROR)
 			return -1;
 		p->invitestate = INV_CALLING;
@@ -19766,7 +19768,7 @@
 			} else if (p->t38.state == T38_DISABLED) {
 				/* If this is not a re-invite or something to ignore - it's critical */
 				ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
-				transmit_response_with_sdp(p, "200 OK", req, (reinvite ? XMIT_RELIABLE : (req->ignore ?  XMIT_UNRELIABLE : XMIT_CRITICAL)), p->session_modify == TRUE ? FALSE:TRUE); 
+				transmit_response_with_sdp(p, "200 OK", req, (reinvite ? XMIT_RELIABLE : (req->ignore ?  XMIT_UNRELIABLE : XMIT_CRITICAL)), p->session_modify == TRUE ? FALSE : TRUE, FALSE); 
 			}
 
 			p->invitestate = INV_TERMINATED;




More information about the asterisk-commits mailing list