From 8d558608522e8a9f06f760db136335599c4ff43d Mon Sep 17 00:00:00 2001 From: Liviu Chircu Date: Thu, 12 Sep 2019 16:43:40 +0300 Subject: [PATCH] dialog: Fix broken Re-INVITE pinging timeouts Commit 0d026b9 introduced a regression where the Re-INVITE pinging timeouts would not work anymore. Fixes #1797 (cherry picked from commit 295f4ba92daad93aefb09b01067e903ff7a77562) --- modules/dialog/dlg_req_within.c | 3 ++- modules/dialog/dlg_req_within.h | 2 +- modules/dialog/dlg_timer.c | 29 +++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/modules/dialog/dlg_req_within.c b/modules/dialog/dlg_req_within.c index 9d62ce10e61..e71127c1abd 100644 --- a/modules/dialog/dlg_req_within.c +++ b/modules/dialog/dlg_req_within.c @@ -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); diff --git a/modules/dialog/dlg_req_within.h b/modules/dialog/dlg_req_within.h index a129b8e0838..c72f12c1c70 100644 --- a/modules/dialog/dlg_req_within.h +++ b/modules/dialog/dlg_req_within.h @@ -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 diff --git a/modules/dialog/dlg_timer.c b/modules/dialog/dlg_timer.c index c008f89d729..eb626222f00 100644 --- a/modules/dialog/dlg_timer.c +++ b/modules/dialog/dlg_timer.c @@ -698,17 +698,21 @@ 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; } @@ -716,14 +720,15 @@ int dlg_handle_seq_reply(struct dlg_cell *dlg, struct sip_msg* rpl, { /* 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; } @@ -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) @@ -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, @@ -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, @@ -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)