Skip to content

Commit

Permalink
tracer: fix refs for multiple transactions in b2b scenarios
Browse files Browse the repository at this point in the history
Many thanks to @vtzan for reporting and intensive testing
  • Loading branch information
razvancrainea committed Jun 30, 2023
1 parent e0fe732 commit 0286958
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions modules/tracer/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,11 @@ static void free_trace_info_shm(void *param, int type)
trace_info_unref(info,1);
}

static void unref_trace_info(void *param)
{
trace_info_unref(param, 1);
}

static void free_trace_info_tm(void *param)
{
free_trace_info_shm(param, TRACE_TRANSACTION);
Expand Down Expand Up @@ -1441,14 +1446,16 @@ static int trace_b2b_transaction(struct sip_msg* msg, void *trans, void* param)
/* arm transaction callbacks for futher tracing*/

if(tmb.register_tmcb( NULL, t, TMCB_MSG_MATCHED_IN,
trace_tm_in, info, 0) <=0) {
trace_tm_in, info, unref_trace_info) <=0) {
LM_ERR("can't register TM MATCH IN callback\n");
return -1;
}

trace_info_ref(info, 2);
if(tmb.register_tmcb( NULL, t, TMCB_MSG_SENT_OUT,
trace_tm_out, info, 0) <=0) {
trace_tm_out, info, unref_trace_info) <=0) {
LM_ERR("can't register TM SEND OUT callback\n");
trace_info_unref(info, 2);
return -1;
}

Expand Down Expand Up @@ -1502,18 +1509,19 @@ static int trace_transaction(struct sip_msg* msg, trace_info_p info, int reverse
msg->msg_flags |= FL_USE_SIPTRACE;

if(tmb.register_tmcb( msg, 0, TMCB_MSG_MATCHED_IN,
reverse_dir?trace_tm_in_rev:trace_tm_in, info, 0) <=0) {
reverse_dir?trace_tm_in_rev:trace_tm_in, info, unref_trace_info) <=0) {
LM_ERR("can't register TM MATCH IN callback\n");
return -1;
}

trace_info_ref(info, 2);
if(tmb.register_tmcb( msg, 0, TMCB_MSG_SENT_OUT,
reverse_dir?trace_tm_out_rev:trace_tm_out, info, free_trace_info_tm) <=0) {
LM_ERR("can't register TM SEND OUT callback\n");
trace_info_unref(info, 2);
return -1;
}

trace_info_ref(info,1);
return 0;
}

Expand Down

0 comments on commit 0286958

Please sign in to comment.