Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 233719) +++ channels/chan_sip.c (working copy) @@ -3118,13 +3118,19 @@ if (sscanf(p->lastmsg, "Tx: %30s", method_str) == 1 || sscanf(p->lastmsg, "Rx: %30s", method_str) == 1) { if (method_match(SIP_CANCEL, method_str) || method_match(SIP_BYE, method_str)) { p->needdestroy = 1; + return 10000; } } - return 10000; + + /* Give them twice the maximum interval to respond, then really kill the dialog. */ + snprintf(p->lastmsg, sizeof(p->lastmsg), "Tx: CANCEL (autodestruct)\n"); + return (p->timer_t1 < 500 ? 500 : p->timer_t1) * 64 * 2; } else { /* They've had their chance to respond. Time to bail */ __sip_pretend_ack(p); } + p->needdestroy = 1; + p->invitestate = INV_CANCELLED; } if (p->subscribed == MWI_NOTIFICATION) @@ -4523,6 +4529,10 @@ ast_queue_control(p->owner, AST_CONTROL_CONGESTION); ast_channel_unlock(p->owner); } + p->invitestate = INV_CANCELLED; + stop_media_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */ + p->needdestroy = 1; + sip_alreadygone(p); } sip_pvt_unlock(p); return 0;