From 24ba3ed467bebc1f029e5c0627225f8d54163143 Mon Sep 17 00:00:00 2001 From: Bogdan-Andrei Iancu Date: Mon, 24 Nov 2014 11:44:14 +0200 Subject: [PATCH] Fix double tracing in trace_dialog(). If user AVPs are set and the trace flas is not, the code was forcing the tracing flag which was producing a duplicate of the trace. Now, the flags status (on/off) is also stored in the dialog (as var) and restore later, for each sequential request. --- modules/siptrace/siptrace.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/siptrace/siptrace.c b/modules/siptrace/siptrace.c index 3ec5b3e391b..81f553bc49e 100644 --- a/modules/siptrace/siptrace.c +++ b/modules/siptrace/siptrace.c @@ -119,6 +119,8 @@ static str toip_column = str_init("toip"); /* 07 */ static str fromtag_column = str_init("fromtag"); /* 08 */ static str direction_column = str_init("direction"); /* 09 */ +static str st_flag_val = str_init("_st_XX_flag_43"); + static char *trace_flag_str = 0; int trace_flag = -1; int trace_on = 0; @@ -640,7 +642,8 @@ static void trace_transaction(struct dlg_cell* dlg, int type, }while(1); /* set the flag */ - params->msg->flags |= trace_flag; + if ( dlgb.fetch_dlg_value( dlg, &st_flag_val, &avp_value.s, 0)!=0 ) + params->msg->flags |= trace_flag; params->msg->msg_flags |= FL_USE_SIPTRACE; /* trace current request */ sip_trace(params->msg); @@ -688,6 +691,14 @@ static int trace_dialog(struct sip_msg *msg) return -1; } + /* any need to do tracing here ? check the triggers */ + avp=search_first_avp(traced_user_avp_type, traced_user_avp, + &avp_value, 0); + if (avp==NULL && (msg->flags&trace_flag)==0) { + LM_DBG("Nothing to trace here\n"); + return -1; + } + if (dlgb.create_dlg(msg,0)<1) { LM_ERR("failed to create dialog\n"); return -1; @@ -709,8 +720,6 @@ static int trace_dialog(struct sip_msg *msg) them for each transactin from the dialog */ if(traced_user_avp>=0) { n = 0; - avp=search_first_avp(traced_user_avp_type, traced_user_avp, - &avp_value, 0); while(avp!=NULL) { /* generate a name */ name = generate_val_name(n); @@ -726,7 +735,11 @@ static int trace_dialog(struct sip_msg *msg) } /* set the flag to trace the rest of the transaction */ - msg->flags |= trace_flag; + if (msg->flags&trace_flag) { + avp_value.s.s = "1"; + avp_value.s.len = 1; + dlgb.store_dlg_value( dlg, &st_flag_val, &avp_value.s); + } /* trace current request */ sip_trace(msg);