Skip to content

Commit

Permalink
core: improve script_trace() performance with a wrapper macro
Browse files Browse the repository at this point in the history
  • Loading branch information
liviuchircu committed Mar 1, 2014
1 parent 0e37b92 commit a5cd55b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
21 changes: 7 additions & 14 deletions action.c
Expand Up @@ -109,8 +109,6 @@ action_elem_t *route_params = NULL;
int route_params_number = 0;


void script_trace(char *class, char *action, struct sip_msg *msg, int line) ;

/* run actions from a route */
/* returns: 0, or 1 on success, <0 on error */
/* (0 if drop or break encountered, 1 if not ) */
Expand Down Expand Up @@ -2004,21 +2002,18 @@ int do_action(struct action* a, struct sip_msg* msg)
}

/**
* If enabled, prints the current point of execution in the OpenSIPS script
* Params:
* - class - optional, string to be printed meaning the class of action (if any)
* - action - mandatory, string with the name of action
* - msg - mandatory, sip message
* - line - line in script
* prints the current point of execution in the OpenSIPS script
*
* @class - optional, string to be printed meaning the class of action (if any)
* @action - mandatory, string with the name of action
* @msg - mandatory, sip message
* @line - line in script
*/
void script_trace(char *class, char *action, struct sip_msg *msg, int line)
void __script_trace(char *class, char *action, struct sip_msg *msg, int line)
{
gparam_t param;
str val;

if (use_script_trace == 0)
return;

param.type = GPARAM_TYPE_PVE;
param.v.pve = &script_trace_elem;

Expand All @@ -2040,5 +2035,3 @@ void script_trace(char *class, char *action, struct sip_msg *msg, int line)
class?class:"", action, val.len, val.s);
}
}


9 changes: 9 additions & 0 deletions action.h
Expand Up @@ -37,6 +37,7 @@
#define ACT_FL_DROP 4

extern int action_flags;
extern int use_script_trace;

#define LONGEST_ACTION_SIZE 5

Expand All @@ -53,4 +54,12 @@ int run_top_route(struct action* a, struct sip_msg* msg);
int run_action_list(struct action* a, struct sip_msg* msg);
void run_error_route(struct sip_msg* msg, int force_reset);

#define script_trace(class, action, msg, line) \
do { \
if (use_script_trace) \
__script_trace(class, action, msg, line); \
} while (0)

void __script_trace(char *class, char *action, struct sip_msg *msg, int line);

#endif

0 comments on commit a5cd55b

Please sign in to comment.