From 93f3abb3e839dfe23caf8377393eb555b95b642a Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Wed, 13 Jun 2007 19:57:38 +0000 Subject: [PATCH] Move the logic for destroying a call when no response is received to a BYE outside of the block that checks for FLAG_FATAL to be set. This flag is only set when the packet is transmitted with the reliability set to XMIT_CRITICAL when the original packet is transmitted. A BYE is always sent with it set to XMIT_RELIABLE, meaning this code could never be encountered. This resulted in seeing some SIP channels that would never go away with the last packet sent being a BYE. (part of issue #9235, patch from jcmoore) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@69183 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index b03ef1fbae..6a61a018a8 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1934,16 +1934,11 @@ static int retrans_pkt(void *data) usleep(1); ast_mutex_lock(&pkt->owner->lock); } + if (pkt->owner->owner && !pkt->owner->owner->hangupcause) pkt->owner->owner->hangupcause = AST_CAUSE_NO_USER_RESPONSE; - if (pkt->method == SIP_BYE) { - /* Ok, we're not getting answers on SIP BYE's. Who cares? - let's take the call down anyway. */ - if (pkt->owner->owner) - ast_channel_unlock(pkt->owner->owner); - append_history(pkt->owner, "ByeFailure", "Remote peer doesn't respond to bye. Destroying call anyway."); - ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY); - } else if (pkt->owner->owner) { + + if (pkt->owner->owner) { sip_alreadygone(pkt->owner); ast_log(LOG_WARNING, "Hanging up call %s - no reply to our critical packet.\n", pkt->owner->callid); ast_queue_hangup(pkt->owner->owner); @@ -1960,6 +1955,15 @@ static int retrans_pkt(void *data) } } } + + if (pkt->method == SIP_BYE) { + /* We're not getting answers on SIP BYE's. Tear down the call anyway. */ + if (pkt->owner->owner) + ast_channel_unlock(pkt->owner->owner); + append_history(pkt->owner, "ByeFailure", "Remote peer doesn't respond to bye. Destroying call anyway."); + ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY); + } + /* In any case, go ahead and remove the packet */ for (prev = NULL, cur = pkt->owner->packets; cur; prev = cur, cur = cur->next) { if (cur == pkt)