Module: kamailio
Branch: 5.8
Commit: 2b0b8714b7f75d13be6f8156f4f8efbf6401f0b7
URL: 
https://github.com/kamailio/kamailio/commit/2b0b8714b7f75d13be6f8156f4f8efbf6401f0b7

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-03-20T07:30:45+01:00

dialog: enforce second bye towards callee for dlg_bye()

- GH #4169

(cherry picked from commit 7de1693573fc08e54db1955095d66c495b2051b9)
(cherry picked from commit 0cbf7eede6dbd3198664160b77d1b4d0337833b8)

---

Modified: src/modules/dialog/dlg_req_within.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/2b0b8714b7f75d13be6f8156f4f8efbf6401f0b7.diff
Patch: 
https://github.com/kamailio/kamailio/commit/2b0b8714b7f75d13be6f8156f4f8efbf6401f0b7.patch

---

diff --git a/src/modules/dialog/dlg_req_within.c 
b/src/modules/dialog/dlg_req_within.c
index 06111e9783f..0b7b140fd61 100644
--- a/src/modules/dialog/dlg_req_within.c
+++ b/src/modules/dialog/dlg_req_within.c
@@ -374,7 +374,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;
@@ -384,16 +385,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,
@@ -841,7 +841,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);
@@ -862,8 +862,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);
 

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to