Jelajahi Sumber

core: store current executed cfg action in a global variable

- can be retrieved by module to access name of config file and the line
Daniel-Constantin Mierla 12 tahun lalu
induk
melakukan
4294b7bf3b
2 mengubah file dengan 11 tambahan dan 0 penghapusan
  1. 10 0
      action.c
  2. 1 0
      action.h

+ 10 - 0
action.c

@@ -111,6 +111,14 @@
 int _last_returned_code  = 0;
 struct onsend_info* p_onsend=0; /* onsend route send info */
 
+/* current action executed from config file */
+static cfg_action_t *_cfg_crt_action = 0;
+
+/* return currect action executed from config file */
+cfg_action_t *get_cfg_crt_action(void)
+{
+	return _cfg_crt_action;
+}
 
 
 /* handle the exit code of a module function call.
@@ -1572,7 +1580,9 @@ int run_actions(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
 	for (t=a; t!=0; t=t->next){
 		if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0))
 			ms = TICKS_TO_MS(get_ticks_raw());
+		_cfg_crt_action = t;
 		ret=do_action(h, t, msg);
+		_cfg_crt_action = 0;
 		if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)) {
 			ms = TICKS_TO_MS(get_ticks_raw()) - ms;
 			if(ms >= cfg_get(core, core_cfg, latency_limit_action)) {

+ 1 - 0
action.h

@@ -68,6 +68,7 @@ int run_actions(struct run_act_ctx* c, struct action* a, struct sip_msg* msg);
 
 int run_top_route(struct action* a, sip_msg_t* msg, struct run_act_ctx* c);
 
+cfg_action_t *get_cfg_crt_action(void);
 
 #ifdef USE_LONGJMP
 int run_actions_safe(struct run_act_ctx* c, struct action* a,