--- chan_sip.c.br14.89184.orig 2007-11-13 14:09:36.000000000 +0100 +++ chan_sip.c.br14.89184 2007-11-13 14:35:54.000000000 +0100 @@ -14995,6 +14995,22 @@ ast_log(LOG_DEBUG, "Ignoring out of order response %d (expecting %d)\n", seqno, p->ocseq); return -1; } else if (p->ocseq && (p->ocseq != seqno) && (seqno != p->lastnoninvite)) { + + /* If we sent multiple outstanding requests, this incoming response can be a "late" response. + * At least, we must cancel retransmits. + * This is only a workaround until multiple outstanding transactions are fully supported. */ + if (e && (e = ast_skip_blanks(e)) && sscanf(e, "%d %n", &respid, &len) == 1) { + const char *msg = strchr(cseq, ' '); + int sipmethod = find_sip_method(msg ? msg + 1 : ""); + + if (option_debug > 3) + ast_log(LOG_DEBUG, "Cancel retransmits (if any) for CSeq %d Method %s\n", seqno, sip_methods[sipmethod].text); + if ((respid >= 100) && (respid <= 199)) + __sip_semi_ack(p, seqno, 0, sipmethod); + else + __sip_ack(p, seqno, 0, sipmethod); + } + /* ignore means "don't do anything with it" but still have to respond appropriately */ ignore = TRUE;