Skip to content

Commit

Permalink
Respond with ACK first before hanging up call for dialog fork (#3445)
Browse files Browse the repository at this point in the history
  • Loading branch information
sauwming committed Mar 20, 2023
1 parent 651df5b commit 15902a8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions pjsip/include/pjsip/sip_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ struct pjsip_dialog
pj_bool_t uac_has_2xx;/**< UAC has received 2xx response? */
pj_bool_t secure; /**< Use secure transport? */
pj_bool_t add_allow; /**< Add Allow header in requests? */
pj_bool_t ack_sent; /**< ACK has been sent? */
pjsip_cid_hdr *call_id; /**< Call-ID header. */
pjsip_route_hdr route_set; /**< Route set. */
pj_bool_t route_set_frozen; /**< Route set has been set. */
Expand Down
5 changes: 4 additions & 1 deletion pjsip/src/pjsip/sip_dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,8 @@ PJ_DEF(pj_status_t) pjsip_dlg_send_request( pjsip_dialog *dlg,
}

} else {
dlg->ack_sent = PJ_TRUE;

/* Set transport selector */
pjsip_tx_data_set_transport(tdata, &dlg->tp_sel);

Expand Down Expand Up @@ -2079,7 +2081,8 @@ void pjsip_dlg_on_rx_response( pjsip_dialog *dlg, pjsip_rx_data *rdata )
pj_status_t status;

if (rdata->msg_info.cseq->method.id==PJSIP_INVITE_METHOD &&
rdata->msg_info.msg->line.status.code/100 == 2)
rdata->msg_info.msg->line.status.code/100 == 2 &&
!dlg->ack_sent)
{
pjsip_tx_data *ack;

Expand Down
8 changes: 7 additions & 1 deletion pjsip/src/pjsua-lib/pjsua_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -5106,7 +5106,7 @@ pjsip_dialog* on_dlg_forked(pjsip_dialog *dlg, pjsip_rx_data *res)
res->msg_info.msg->line.status.code/100 == 2)
{
pjsip_dialog *forked_dlg;
pjsip_tx_data *bye;
pjsip_tx_data *bye, *ack;
pj_status_t status;

/* Create forked dialog */
Expand All @@ -5116,6 +5116,12 @@ pjsip_dialog* on_dlg_forked(pjsip_dialog *dlg, pjsip_rx_data *res)

pjsip_dlg_inc_lock(forked_dlg);

/* Respond with ACK first */
status = pjsip_dlg_create_request(forked_dlg, &pjsip_ack_method,
res->msg_info.cseq->cseq, &ack);
if (status == PJ_SUCCESS)
pjsip_dlg_send_request(forked_dlg, ack, -1, NULL);

/* Disconnect the call */
status = pjsip_dlg_create_request(forked_dlg, pjsip_get_bye_method(),
-1, &bye);
Expand Down
8 changes: 3 additions & 5 deletions tests/pjsua/scripts-sipp/uas-forked-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@
]]>
</send>

<!-- Receive ACK -->
<recv request="ACK" optional="false">
</recv>

<!-- Receive BYE (for leg 2) -->
<recv request="BYE" optional="false">
Expand All @@ -115,11 +118,6 @@
</send>


<!-- Receive ACK -->
<recv request="ACK" optional="false">
</recv>


<!-- definition of the response time repartition table (unit is ms) -->
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>

Expand Down

0 comments on commit 15902a8

Please sign in to comment.