Browse code

Merge 498aa35987bcfd329cf5a4879eb63888ff8ef225 into 60f04b6d6f51b55294d22722df3f351a76cbfb9b

Julien Chavanton authored on 28/09/2020 16:49:27 • GitHub committed on 28/09/2020 16:49:27
Showing 1 changed files
... ...
@@ -865,6 +865,7 @@ static inline struct dlg_cell* internal_get_dlg(unsigned int h_entry,
865 865
 						unsigned int *dir, int mode)
866 866
 {
867 867
 	struct dlg_cell *dlg;
868
+	struct dlg_cell *dlg_no_totag=NULL;
868 869
 	struct dlg_entry *d_entry;
869 870
 
870 871
 	d_entry = &(d_table->entries[h_entry]);
... ...
@@ -876,13 +877,24 @@ static inline struct dlg_cell* internal_get_dlg(unsigned int h_entry,
876 877
 		if (match_dialog( dlg, callid, ftag, ttag, dir)==1) {
877 878
 			ref_dlg_unsafe(dlg, 1);
878 879
 			if(likely(mode==0)) dlg_unlock( d_table, d_entry);
879
-			LM_DBG("dialog callid='%.*s' found on entry %u, dir=%d\n",
880
-				callid->len, callid->s,h_entry,*dir);
880
+
881
+			/* If to-tag is empty continue to search in case another dialog is found with a matching to-tag. */
882
+			if (dlg->tag[1].len == 0) {
883
+				dlg_no_totag=dlg;
884
+				LM_DBG("dialog callid='%.*s' found on entry %u, dir=%d\n",
885
+					callid->len, callid->s,h_entry,*dir);
886
+				continue;
887
+			}
888
+			LM_DBG("dialog callid='%.*s' found on entry %u, dir=%d to-tag='%.*s'\n",
889
+				callid->len, callid->s,h_entry,*dir, dlg->tag[1].len, dlg->tag[1].s);
890
+
881 891
 			return dlg;
882 892
 		}
883 893
 	}
884 894
 
885 895
 	if(likely(mode==0)) dlg_unlock( d_table, d_entry);
896
+	if (dlg_no_totag) return dlg_no_totag;
897
+
886 898
 	LM_DBG("no dialog callid='%.*s' found\n", callid->len, callid->s);
887 899
 	return 0;
888 900
 }