Bläddra i källkod

core: new global parameter max_recursive_level

- replace define ROUTE_MAX_REC_LEV with config paramter
- number of allowed recusive levels can be set in config now
- it affects calls of route blocks and chained if { ... } else if { ...
  } else ...
Daniel-Constantin Mierla 11 år sedan
förälder
incheckning
d1c6071830
5 ändrade filer med 16 tillägg och 4 borttagningar
  1. 9 1
      action.c
  2. 2 0
      action.h
  3. 3 0
      cfg.lex
  4. 2 0
      cfg.y
  5. 0 3
      config.h

+ 9 - 1
action.c

@@ -114,6 +114,14 @@ struct onsend_info* p_onsend=0; /* onsend route send info */
 /* current action executed from config file */
 static cfg_action_t *_cfg_crt_action = 0;
 
+/*!< maximum number of recursive calls for blocks of actions */
+static unsigned int max_recursive_level = 256;
+
+void set_max_recursive_level(unsigned int lev)
+{
+	max_recursive_level = lev;
+}
+
 /* return current action executed from config file */
 cfg_action_t *get_cfg_crt_action(void)
 {
@@ -1567,7 +1575,7 @@ int run_actions(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
 
 	ret=E_UNSPEC;
 	h->rec_lev++;
-	if (unlikely(h->rec_lev>ROUTE_MAX_REC_LEV)){
+	if (unlikely(h->rec_lev>max_recursive_level)){
 		LOG(L_ERR, "WARNING: too many recursive routing table lookups (%d)"
 					" giving up!\n", h->rec_lev);
 		ret=E_UNSPEC;

+ 2 - 0
action.h

@@ -72,6 +72,8 @@ cfg_action_t *get_cfg_crt_action(void);
 int get_cfg_crt_line(void);
 char *get_cfg_crt_name(void);
 
+void set_max_recursive_level(unsigned int lev);
+
 #ifdef USE_LONGJMP
 int run_actions_safe(struct run_act_ctx* c, struct action* a,
 						struct sip_msg* msg);

+ 3 - 0
cfg.lex

@@ -482,6 +482,8 @@ VERSION_TABLE_CFG		"version_table"
 
 SERVER_ID     "server_id"
 
+MAX_RECURSIVE_LEVEL		"max_recursive_level"
+
 LATENCY_LOG				latency_log
 LATENCY_LIMIT_DB		latency_limit_db
 LATENCY_LIMIT_ACTION	latency_limit_action
@@ -917,6 +919,7 @@ IMPORTFILE      "import_file"
 									return HTTP_REPLY_PARSE; }
 <INITIAL>{VERSION_TABLE_CFG}  { count(); yylval.strval=yytext; return VERSION_TABLE_CFG;}
 <INITIAL>{SERVER_ID}  { count(); yylval.strval=yytext; return SERVER_ID;}
+<INITIAL>{MAX_RECURSIVE_LEVEL}  { count(); yylval.strval=yytext; return MAX_RECURSIVE_LEVEL;}
 <INITIAL>{LATENCY_LOG}  { count(); yylval.strval=yytext; return LATENCY_LOG;}
 <INITIAL>{MSG_TIME}  { count(); yylval.strval=yytext; return MSG_TIME;}
 <INITIAL>{LATENCY_LIMIT_DB}  { count(); yylval.strval=yytext; return LATENCY_LIMIT_DB;}

+ 2 - 0
cfg.y

@@ -536,6 +536,7 @@ extern char *finame;
 %token VERSION_TABLE_CFG
 %token CFG_DESCRIPTION
 %token SERVER_ID
+%token MAX_RECURSIVE_LEVEL
 %token LATENCY_LOG
 %token LATENCY_LIMIT_DB
 %token LATENCY_LIMIT_ACTION
@@ -1559,6 +1560,7 @@ assign_stm:
 	| HTTP_REPLY_PARSE EQUAL NUMBER { http_reply_parse=$3; }
 	| HTTP_REPLY_PARSE EQUAL error { yyerror("boolean value expected"); }
     | SERVER_ID EQUAL NUMBER { server_id=$3; }
+    | MAX_RECURSIVE_LEVEL EQUAL NUMBER { set_max_recursive_level($3); }
     | LATENCY_LOG EQUAL NUMBER { default_core_cfg.latency_log=$3; }
 	| LATENCY_LOG EQUAL error  { yyerror("number  expected"); }
     | LATENCY_LIMIT_DB EQUAL NUMBER { default_core_cfg.latency_limit_db=$3; }

+ 0 - 3
config.h

@@ -66,9 +66,6 @@
 #define EVENT_RT_NO RT_NO 		/*!< event_route routing tables number */
 #define DEFAULT_RT 0 			/*!< default routing table */
 
-#define MAX_REC_LEV 100 		/*!< maximum number of recursive calls */
-#define ROUTE_MAX_REC_LEV 100 		/*!< maximum number of recursive calls for route()*/
-
 #define MAX_URI_SIZE 1024		/*!< Max URI size used when rewriting URIs */
 
 #define MAX_PATH_SIZE 256 		/*!< Maximum length of path header buffer */