浏览代码

dialog: enforce second bye towards callee for dlg_bye()

- GH #4169
Daniel-Constantin Mierla 6 月之前
父节点
当前提交
7de1693573
共有 1 个文件被更改,包括 10 次插入8 次删除
  1. 10 8
      src/modules/dialog/dlg_req_within.c

+ 10 - 8
src/modules/dialog/dlg_req_within.c

@@ -376,7 +376,8 @@ error:
  * 		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);