[asterisk-commits] trunk r29266 - /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun May 21 17:29:12 MST 2006


Author: rizzo
Date: Sun May 21 19:29:12 2006
New Revision: 29266

URL: http://svn.digium.com/view/asterisk?rev=29266&view=rev
Log:
minor logic simplification in get_sip_pvt_byid_locked()


Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=29266&r1=29265&r2=29266&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sun May 21 19:29:12 2006
@@ -7100,10 +7100,10 @@
 	- This means that in some transactions, totag needs to be their tag :-)
 	  depending upon the direction
 */
-static struct sip_pvt *get_sip_pvt_byid_locked(char *callid, char *totag, char *fromtag) 
-{
-	struct sip_pvt *sip_pvt_ptr = NULL;
-	
+static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *totag, const char *fromtag) 
+{
+	struct sip_pvt *sip_pvt_ptr;
+
 	/* Search interfaces and find the match */
 	ast_mutex_lock(&iflock);
 
@@ -7131,16 +7131,15 @@
 			}
 
 			if (option_debug > 3 && totag)				 
-				ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n", ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING", sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
-
-			if (sip_pvt_ptr->owner) {
-				while(ast_channel_trylock(sip_pvt_ptr->owner)) {
-					ast_mutex_unlock(&sip_pvt_ptr->lock);
-					usleep(1);
-					ast_mutex_lock(&sip_pvt_ptr->lock);
-					if (!sip_pvt_ptr->owner)
-						break;
-				}
+				ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n",
+					ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING",
+					sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
+
+			/* deadlock avoidance... */
+			while (sip_pvt_ptr->owner && ast_mutex_trylock(&sip_pvt_ptr->owner->lock)) {
+				ast_mutex_unlock(&sip_pvt_ptr->lock);
+				usleep(1);
+				ast_mutex_lock(&sip_pvt_ptr->lock);
 			}
 			break;
 		}



More information about the asterisk-commits mailing list