Skip to content

Commit

Permalink
Fix double tracing in trace_dialog().
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bogdan-iancu committed Nov 24, 2014
1 parent 41408f0 commit 24ba3ed
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions modules/siptrace/siptrace.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 24ba3ed

Please sign in to comment.