diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-22 00:29:12 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-22 00:29:12 +0000 |
commit | 4b2c4b1533303a768a0eeaed4bf91cc845e86842 (patch) | |
tree | 5264c476b1995607a6a9779f78d37d79bc6dffe2 /channels/chan_sip.c | |
parent | c730d49e31119a76b3396a408837c231e090af0d (diff) |
minor logic simplification in get_sip_pvt_byid_locked()
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@29266 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 25 |
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; } |