Skip to content

Commit

Permalink
dialog: Fix broken Re-INVITE pinging timeouts
Browse files Browse the repository at this point in the history
Commit 0d026b9 introduced a regression where the Re-INVITE pinging
timeouts would not work anymore.

Fixes #1797

(cherry picked from commit 295f4ba)
  • Loading branch information
liviuchircu committed Sep 12, 2019
1 parent 1092bf4 commit 8d55860
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
3 changes: 2 additions & 1 deletion modules/dialog/dlg_req_within.c
Expand Up @@ -705,7 +705,8 @@ static void dlg_sequential_reply(struct cell* t, int type, struct tmcb_params* p
p = (struct dlg_sequential_param *)(*ps->param);
dlg = p->dlg;

if (dlg_handle_seq_reply(dlg, rpl, statuscode, p->leg) < 0) {
if (dlg_handle_seq_reply(dlg, rpl, statuscode, p->leg,
dlg_has_reinvite_pinging(dlg)) < 0) {
LM_ERR("Bad reply %d for callid %.*s\n",
statuscode, dlg->callid.len,dlg->callid.s);
dlg_async_response(p, rpl, statuscode);
Expand Down
2 changes: 1 addition & 1 deletion modules/dialog/dlg_req_within.h
Expand Up @@ -192,5 +192,5 @@ int send_leg_msg(struct dlg_cell *dlg,str *method,int src_leg,int dst_leg,
str *hdrs,str *body,dlg_request_callback func,void *param,
dlg_release_func release,char *reply_marker);
int dlg_handle_seq_reply(struct dlg_cell *dlg, struct sip_msg* rpl,
int statuscode, int leg);
int statuscode, int leg, int is_reinvite_rpl);
#endif
29 changes: 17 additions & 12 deletions modules/dialog/dlg_timer.c
Expand Up @@ -698,32 +698,37 @@ void get_timeout_dlgs(struct dlg_ping_list **expired,
}

int dlg_handle_seq_reply(struct dlg_cell *dlg, struct sip_msg* rpl,
int statuscode, int leg)
int statuscode, int leg, int is_reinvite_rpl)
{
char *ping_status = is_reinvite_rpl ? &dlg->legs[leg].reinvite_confirmed :
&dlg->legs[leg].reply_received;

LM_DBG("Status Code received = [%d]\n", statuscode);

if (rpl == FAKED_REPLY || statuscode == 408) {
/* timeout occurred, nothing else to do now
* next time timer fires, it will detect ping reply was not received
*/
LM_INFO("terminating dialog ( due to timeout ) "
"with callid = [%.*s] \n",dlg->callid.len,dlg->callid.s);
dlg->legs[leg].reply_received = DLG_PING_FAIL;
LM_INFO("terminating dialog due to ping timeout on %s leg, "
"ci: [%.*s]\n", leg == DLG_CALLER_LEG ? "caller" : "callee",
dlg->callid.len, dlg->callid.s);
*ping_status = DLG_PING_FAIL;
return -1;
}

if (statuscode == 481)
{
/* call/transaction does not exist
* terminate the dialog */
LM_INFO("terminating dialog ( due to 481 ) "
"with callid = [%.*s] \n",dlg->callid.len,dlg->callid.s);
LM_INFO("terminating dialog due to 481 ping reply on %s leg, "
"ci: [%.*s]\n", leg == DLG_CALLER_LEG ? "caller" : "callee",
dlg->callid.len, dlg->callid.s);

dlg->legs[leg].reply_received = DLG_PING_FAIL;
*ping_status = DLG_PING_FAIL;
return -1;
}

dlg->legs[leg].reply_received = DLG_PING_SUCCESS;
*ping_status = DLG_PING_SUCCESS;
return 0;
}

Expand All @@ -749,7 +754,7 @@ void reply_from_caller(struct cell* t, int type, struct tmcb_params* ps)
statuscode = ps->code;
dlg = *(ps->param);

dlg_handle_seq_reply(dlg, rpl, statuscode, DLG_CALLER_LEG);
dlg_handle_seq_reply(dlg, rpl, statuscode, DLG_CALLER_LEG, 0);
}

void reinvite_reply_from_caller(struct cell* t, int type, struct tmcb_params* ps)
Expand All @@ -773,7 +778,7 @@ void reinvite_reply_from_caller(struct cell* t, int type, struct tmcb_params* ps
statuscode = ps->code;
dlg = *(ps->param);

dlg_handle_seq_reply(dlg, rpl, statuscode, DLG_CALLER_LEG);
dlg_handle_seq_reply(dlg, rpl, statuscode, DLG_CALLER_LEG, 1);
}

/* Duplicate code for the sake of quickly knowing where the reply came from,
Expand All @@ -799,7 +804,7 @@ void reply_from_callee(struct cell* t, int type, struct tmcb_params* ps)
statuscode = ps->code;
dlg = *(ps->param);

dlg_handle_seq_reply(dlg, rpl, statuscode, callee_idx(dlg));
dlg_handle_seq_reply(dlg, rpl, statuscode, callee_idx(dlg), 0);
}

/* Duplicate code for the sake of quickly knowing where the reply came from,
Expand All @@ -825,7 +830,7 @@ void reinvite_reply_from_callee(struct cell* t, int type, struct tmcb_params* ps
statuscode = ps->code;
dlg = *(ps->param);

dlg_handle_seq_reply(dlg, rpl, statuscode, callee_idx(dlg));
dlg_handle_seq_reply(dlg, rpl, statuscode, callee_idx(dlg), 1);
}

void unref_dlg_cb(void *dlg)
Expand Down

0 comments on commit 8d55860

Please sign in to comment.