Browse code

Merge acce1f1a62d3c61512f4f4a34709487baa43534f into 60f04b6d6f51b55294d22722df3f351a76cbfb9b

Julien Chavanton authored on 28/09/2020 16:40:18 • GitHub committed on 28/09/2020 16:40:18
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,6 +877,14 @@ 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);
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 to-tag='%.*s'\n",
885
+				callid->len, callid->s,h_entry,*dir, dlg->tag[1].len, dlg->tag[1].s);
886
+				continue;
887
+			}
879 888
 			LM_DBG("dialog callid='%.*s' found on entry %u, dir=%d\n",
880 889
 				callid->len, callid->s,h_entry,*dir);
881 890
 			return dlg;
... ...
@@ -883,6 +892,8 @@ static inline struct dlg_cell* internal_get_dlg(unsigned int h_entry,
883 892
 	}
884 893
 
885 894
 	if(likely(mode==0)) dlg_unlock( d_table, d_entry);
895
+	if (dlg_no_totag) return dlg_no_totag;
896
+
886 897
 	LM_DBG("no dialog callid='%.*s' found\n", callid->len, callid->s);
887 898
 	return 0;
888 899
 }