@@ -241,16 +241,23 @@ struct rtp_relay_leg *rtp_relay_get_leg(struct rtp_relay_ctx *ctx,
241
241
if (tag && !tag -> len )
242
242
tag = NULL ;
243
243
244
+ LM_RTP_DBG ("searching for tag [%.*s] idx [%d]\n" , tag ?tag -> len :0 , tag ?tag -> s :"" , idx );
245
+
244
246
list_for_each (it , & ctx -> legs ) {
245
247
leg = list_entry (it , struct rtp_relay_leg , list );
246
248
if (tag ) {
247
249
/* match by tag */
248
- if (leg -> tag .len && str_match (tag , & leg -> tag ))
249
- return leg ;
250
- } else if (leg -> index != PV_IDX_ALL && leg -> index == idx )
250
+ if (leg -> tag .len ) {
251
+ if (str_match (tag , & leg -> tag ))
252
+ return leg ;
253
+ continue ;
254
+ }
255
+ }
256
+ if (leg -> index != PV_IDX_ALL && leg -> index == idx )
251
257
return leg ;
252
258
}
253
259
260
+ LM_RTP_DBG ("no leg for tag [%.*s] idx [%d]\n" , tag ?tag -> len :0 , tag ?tag -> s :"" , idx );
254
261
return NULL ;
255
262
}
256
263
@@ -399,12 +406,10 @@ static struct rtp_relay_leg *pv_get_rtp_relay_leg(struct sip_msg *msg,
399
406
LM_ERR ("cannot parse To header!\n" );
400
407
return NULL ;
401
408
}
402
- if (get_to (msg )-> tag_value .len ) {
409
+ if (get_to (msg )-> tag_value .len )
403
410
/* a sequential should always have a to_tag */
404
411
tag = get_to (msg )-> tag_value ;
405
- } else {
406
- idx = rtp_relay_ctx_branch ();
407
- }
412
+ idx = rtp_relay_ctx_branch ();
408
413
} else if (route_type == LOCAL_ROUTE ) {
409
414
/* we always force index 0 for local_route */
410
415
idx = rtp_relay_get_last_branch (ctx , msg );
0 commit comments