Module: kamailio Branch: master Commit: 7de1693573fc08e54db1955095d66c495b2051b9 URL: https://github.com/kamailio/kamailio/commit/7de1693573fc08e54db1955095d66c49...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2025-03-12T11:07:15+01:00
dialog: enforce second bye towards callee for dlg_bye()
- GH #4169
---
Modified: src/modules/dialog/dlg_req_within.c
---
Diff: https://github.com/kamailio/kamailio/commit/7de1693573fc08e54db1955095d66c49... Patch: https://github.com/kamailio/kamailio/commit/7de1693573fc08e54db1955095d66c49...
---
diff --git a/src/modules/dialog/dlg_req_within.c b/src/modules/dialog/dlg_req_within.c index 62b6aea1a9c..7645ebeca37 100644 --- a/src/modules/dialog/dlg_req_within.c +++ b/src/modules/dialog/dlg_req_within.c @@ -376,7 +376,8 @@ static inline int build_extra_hdr( * DLG_CALLER_LEG (0): caller * DLG_CALLEE_LEG (1): callee */ -static inline int send_bye(struct dlg_cell *cell, int dir, str *hdrs) +static inline int send_bye( + struct dlg_cell *cell, int dir, str *hdrs, int enforce) { uac_req_t uac_r; dlg_t *dialog_info; @@ -386,16 +387,15 @@ static inline int send_bye(struct dlg_cell *cell, int dir, str *hdrs) str lhdrs;
/* dialog is already in deleted state, nothing to do */ - if(cell->state == DLG_STATE_DELETED) { + if(cell->state == DLG_STATE_DELETED && enforce == 0) { LM_WARN("dlg [%u:%u] with callid %.*s already in deleted state, BYE " "not sent.\n", cell->h_entry, cell->h_id, cell->callid.len, cell->callid.s); - return 0; + return 1; }
/* Send Cancel or final response for non-confirmed dialogs */ - if(cell->state != DLG_STATE_CONFIRMED_NA - && cell->state != DLG_STATE_CONFIRMED) { + if(cell->state < DLG_STATE_CONFIRMED_NA) { if(cell->t) { if(dir == DLG_CALLER_LEG) { if(d_tmb.t_reply(cell->t->uas.request, bye_early_code, @@ -843,7 +843,7 @@ int dlg_bye(struct dlg_cell *dlg, str *hdrs, int side) LM_ERR("failed to build dlg headers\n"); return -1; } - ret = send_bye(dlg, side, &all_hdrs); + ret = send_bye(dlg, side, &all_hdrs, 0); pkg_free(all_hdrs.s);
dlg_run_event_route(dlg, NULL, dlg->state, DLG_STATE_DELETED); @@ -864,8 +864,10 @@ int dlg_bye_all(struct dlg_cell *dlg, str *hdrs) return -1; }
- ret = send_bye(dlg, DLG_CALLER_LEG, &all_hdrs); - ret |= send_bye(dlg, DLG_CALLEE_LEG, &all_hdrs); + ret = send_bye(dlg, DLG_CALLER_LEG, &all_hdrs, 0); + if(ret == 0) { + ret |= send_bye(dlg, DLG_CALLEE_LEG, &all_hdrs, 1); + }
pkg_free(all_hdrs.s);