[sr-dev] git:master:ba7d1d2e: Merge pull request #2484 from kamailio/jchavanton/dlg_missmatch

GitHub noreply at github.com
Tue Sep 29 17:41:41 CEST 2020


Module: kamailio
Branch: master
Commit: ba7d1d2e586ed22dcc78898eaa08abd61606212a
URL: https://github.com/kamailio/kamailio/commit/ba7d1d2e586ed22dcc78898eaa08abd61606212a

Author: Julien Chavanton <jchavanton at gmail.com>
Committer: GitHub <noreply at github.com>
Date: 2020-09-29T08:41:34-07:00

Merge pull request #2484 from kamailio/jchavanton/dlg_missmatch

dialog: dlg_cell, always check for a to-tag match

---

Modified: src/modules/dialog/dlg_hash.c

---

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

---

diff --git a/src/modules/dialog/dlg_hash.c b/src/modules/dialog/dlg_hash.c
index 5557e87574..93d35f553b 100644
--- a/src/modules/dialog/dlg_hash.c
+++ b/src/modules/dialog/dlg_hash.c
@@ -865,6 +865,7 @@ static inline struct dlg_cell* internal_get_dlg(unsigned int h_entry,
 						unsigned int *dir, int mode)
 {
 	struct dlg_cell *dlg;
+	struct dlg_cell *dlg_no_totag=NULL;
 	struct dlg_entry *d_entry;
 
 	d_entry = &(d_table->entries[h_entry]);
@@ -876,13 +877,24 @@ static inline struct dlg_cell* internal_get_dlg(unsigned int h_entry,
 		if (match_dialog( dlg, callid, ftag, ttag, dir)==1) {
 			ref_dlg_unsafe(dlg, 1);
 			if(likely(mode==0)) dlg_unlock( d_table, d_entry);
-			LM_DBG("dialog callid='%.*s' found on entry %u, dir=%d\n",
-				callid->len, callid->s,h_entry,*dir);
+
+			/* If to-tag is empty continue to search in case another dialog is found with a matching to-tag. */
+			if (dlg->tag[1].len == 0) {
+				dlg_no_totag=dlg;
+				LM_DBG("dialog callid='%.*s' found on entry %u, dir=%d\n",
+					callid->len, callid->s,h_entry,*dir);
+				continue;
+			}
+			LM_DBG("dialog callid='%.*s' found on entry %u, dir=%d to-tag='%.*s'\n",
+				callid->len, callid->s,h_entry,*dir, dlg->tag[1].len, dlg->tag[1].s);
+
 			return dlg;
 		}
 	}
 
 	if(likely(mode==0)) dlg_unlock( d_table, d_entry);
+	if (dlg_no_totag) return dlg_no_totag;
+
 	LM_DBG("no dialog callid='%.*s' found\n", callid->len, callid->s);
 	return 0;
 }




More information about the sr-dev mailing list