diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-09-08 19:38:24 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-09-08 19:38:24 +0000 |
commit | b80fa4ea237e397f9a8978d200bebb400f244458 (patch) | |
tree | 311d1c9a260a939873878d11ac539ddf5592813a /channels | |
parent | 2be6d9d7c174007ac0018fed802364d2115f0283 (diff) |
Fix "potential" deadlock and make not-a-deadlock
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1487 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-x | channels/chan_sip.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 34a4abef8..888bef154 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -421,34 +421,28 @@ static int retrans_pkt(void *data) struct sip_pkt *pkt=data; int res = 0; ast_mutex_lock(&pkt->owner->lock); - if (1 /* !p->owner->needdestroy */) { - if (pkt->retrans < MAX_RETRANS) { - pkt->retrans++; - if (sipdebug) { - if (pkt->owner->nat) - ast_verbose("Retransmitting #%d (NAT):\n%s\n to %s:%d\n", pkt->retrans, pkt->data, inet_ntoa(pkt->owner->recv.sin_addr), ntohs(pkt->owner->recv.sin_port)); - else - ast_verbose("Retransmitting #%d (no NAT):\n%s\n to %s:%d\n", pkt->retrans, pkt->data, inet_ntoa(pkt->owner->sa.sin_addr), ntohs(pkt->owner->sa.sin_port)); - } - __sip_xmit(pkt->owner, pkt->data, pkt->packetlen); - res = 1; - } else { - ast_log(LOG_WARNING, "Maximum retries exceeded on call %s for seqno %d (%s)\n", pkt->owner->callid, pkt->seqno, pkt->resp ? "Response" : "Request"); - pkt->retransid = -1; - if (pkt->owner->owner) { - /* XXX Potential deadlocK?? XXX */ - ast_queue_hangup(pkt->owner->owner, 1); - } else { - /* If no owner, destroy now */ - pkt->owner->needdestroy = 1; - } + if (pkt->retrans < MAX_RETRANS) { + pkt->retrans++; + if (sipdebug) { + if (pkt->owner->nat) + ast_verbose("Retransmitting #%d (NAT):\n%s\n to %s:%d\n", pkt->retrans, pkt->data, inet_ntoa(pkt->owner->recv.sin_addr), ntohs(pkt->owner->recv.sin_port)); + else + ast_verbose("Retransmitting #%d (no NAT):\n%s\n to %s:%d\n", pkt->retrans, pkt->data, inet_ntoa(pkt->owner->sa.sin_addr), ntohs(pkt->owner->sa.sin_port)); } + __sip_xmit(pkt->owner, pkt->data, pkt->packetlen); + res = 1; } else { - /* Don't bother retransmitting. It's about to be killed anyway */ + ast_log(LOG_WARNING, "Maximum retries exceeded on call %s for seqno %d (%s)\n", pkt->owner->callid, pkt->seqno, pkt->resp ? "Response" : "Request"); pkt->retransid = -1; + while(pkt->owner->owner && !ast_mutex_lock(&pkt->owner->owner->lock)) { + ast_mutex_unlock(&pkt->owner->lock); + usleep(1); + ast_mutex_lock(&pkt->owner->lock); + } if (pkt->owner->owner) { /* XXX Potential deadlocK?? XXX */ - ast_queue_hangup(pkt->owner->owner, 1); + ast_queue_hangup(pkt->owner->owner, 0); + ast_mutex_unlock(&pkt->owner->owner->lock); } else { /* If no owner, destroy now */ pkt->owner->needdestroy = 1; |