Index: chan_sip.c =================================================================== --- chan_sip.c (revision 184953) +++ chan_sip.c (working copy) @@ -3711,6 +3711,7 @@ continue; if (cur->is_resp || cur->method == sipmethod) { msg = "Found"; + p->invitestate = INV_TERMINATED; if (!resp && (seqno == p->pendinginvite)) { ast_debug(1, "Acked pending invite %d\n", p->pendinginvite); p->pendinginvite = 0; @@ -20545,15 +20546,14 @@ case SIP_ACK: /* Make sure we don't ignore this */ if (seqno == p->pendinginvite) { - p->invitestate = INV_TERMINATED; p->pendinginvite = 0; - __sip_ack(p, seqno, 1 /* response */, 0); if (find_sdp(req)) { if (process_sdp(p, req, SDP_T38_NONE)) - return -1; + return -1; } - check_pendings(p); } + __sip_ack(p, seqno, 1 /* response */, 0); + check_pendings(p); /* Got an ACK that we did not match. Ignore silently */ if (!p->lastinvite && ast_strlen_zero(p->randdata)) { pvt_set_needdestroy(p, "unmatched ACK");