Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 65966) +++ channels/chan_sip.c (working copy) @@ -1934,14 +1934,7 @@ usleep(1); ast_mutex_lock(&pkt->owner->lock); } - 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); - } 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); @@ -1954,6 +1947,16 @@ ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY); } } + + 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); + } + /* 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)