diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 0b52a86771..8b9f96f749 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2067,6 +2067,14 @@ static int __sip_autodestruct(const void *data) return 10000; /* Reschedule this destruction so that we know that it's gone */ } + /* If there are packets still waiting for delivery, delay the destruction */ + if (p->packets) { + if (option_debug > 2) + ast_log(LOG_DEBUG, "Re-scheduled destruction of SIP call %s\n", p->callid ? p->callid : ""); + append_history(p, "ReliableXmit", "timeout"); + return 10000; + } + /* If we're destroying a subscription, dereference peer object too */ if (p->subscribed == MWI_NOTIFICATION && p->relatedpeer) ASTOBJ_UNREF(p->relatedpeer,sip_destroy_peer); diff --git a/main/channel.c b/main/channel.c index 00e57117b0..c9de79bc07 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1709,6 +1709,8 @@ int ast_hangup(struct ast_channel *chan) detach_spies(chan); /* get rid of spies */ + ast_autoservice_stop(chan); + if (chan->masq) { if (ast_do_masquerade(chan)) ast_log(LOG_WARNING, "Failed to perform masquerade\n");