summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorLuigi Rizzo <rizzo@icir.org>2006-05-22 00:29:12 +0000
committerLuigi Rizzo <rizzo@icir.org>2006-05-22 00:29:12 +0000
commit564ca6394a0ff2cbe325add9e9cd9f400611d995 (patch)
tree5264c476b1995607a6a9779f78d37d79bc6dffe2 /channels
parent15b7465cd22bb9e50750368567a4281d59c1d1b2 (diff)
minor logic simplification in get_sip_pvt_byid_locked()
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@29266 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 397aa2bef..648924a23 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -7100,10 +7100,10 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq)
- 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)
+static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *totag, const char *fromtag)
{
- struct sip_pvt *sip_pvt_ptr = NULL;
-
+ struct sip_pvt *sip_pvt_ptr;
+
/* Search interfaces and find the match */
ast_mutex_lock(&iflock);
@@ -7131,16 +7131,15 @@ static struct sip_pvt *get_sip_pvt_byid_locked(char *callid, char *totag, char *
}
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;
}