From a8d64ee5f21ae6623f371cd8cd615758fec72200 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 24 Jan 2014 11:28:34 +0000 Subject: Fixed #1725: ACK is not sent upon receiving 200/OK retransmission if re-INVITE is sent git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4716 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip-ua/sip_inv.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c index 89fc5510..8fff3ded 100644 --- a/pjsip/src/pjsip-ua/sip_inv.c +++ b/pjsip/src/pjsip-ua/sip_inv.c @@ -398,6 +398,11 @@ static pj_status_t inv_send_ack(pjsip_inv_session *inv, pjsip_event *e) return PJ_EBUG; } + /* Note that with https://trac.pjsip.org/repos/ticket/1725, this + * function can be called to send ACK for previous INVITE 200/OK + * retransmission + */ + PJ_LOG(5,(inv->obj_name, "Received %s, sending ACK", pjsip_rx_data_get_info(rdata))); @@ -618,15 +623,23 @@ static pj_bool_t mod_inv_on_rx_response(pjsip_rx_data *rdata) * If it is, we need to send ACK. */ if (msg->type == PJSIP_RESPONSE_MSG && msg->line.status.code/100==2 && - rdata->msg_info.cseq->method.id == PJSIP_INVITE_METHOD && - inv->invite_tsx == NULL) + rdata->msg_info.cseq->method.id == PJSIP_INVITE_METHOD) { - pjsip_event e; - - PJSIP_EVENT_INIT_RX_MSG(e, rdata); - inv_send_ack(inv, &e); - return PJ_TRUE; + /* The code inside "if" is called the second time 200/OK + * retransmission is received. Also handle the situation + * when we have another re-INVITE on going and 200/OK + * retransmission is received. See: + * https://trac.pjsip.org/repos/ticket/1725 + */ + if (inv->invite_tsx == NULL || + (inv->last_ack && inv->last_ack_cseq==rdata->msg_info.cseq->cseq)) + { + pjsip_event e; + PJSIP_EVENT_INIT_RX_MSG(e, rdata); + inv_send_ack(inv, &e); + return PJ_TRUE; + } } /* No other processing needs to be done here. */ -- cgit v1.2.3