Browse code

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 authored on 29/03/2014 23:22:17
Showing 5 changed files
... ...
@@ -114,6 +114,14 @@ struct onsend_info* p_onsend=0; /* onsend route send info */
114 114
 /* current action executed from config file */
115 115
 static cfg_action_t *_cfg_crt_action = 0;
116 116
 
117
+/*!< maximum number of recursive calls for blocks of actions */
118
+static unsigned int max_recursive_level = 256;
119
+
120
+void set_max_recursive_level(unsigned int lev)
121
+{
122
+	max_recursive_level = lev;
123
+}
124
+
117 125
 /* return current action executed from config file */
118 126
 cfg_action_t *get_cfg_crt_action(void)
119 127
 {
... ...
@@ -1567,7 +1575,7 @@ int run_actions(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
1567 1567
 
1568 1568
 	ret=E_UNSPEC;
1569 1569
 	h->rec_lev++;
1570
-	if (unlikely(h->rec_lev>ROUTE_MAX_REC_LEV)){
1570
+	if (unlikely(h->rec_lev>max_recursive_level)){
1571 1571
 		LOG(L_ERR, "WARNING: too many recursive routing table lookups (%d)"
1572 1572
 					" giving up!\n", h->rec_lev);
1573 1573
 		ret=E_UNSPEC;
... ...
@@ -72,6 +72,8 @@ cfg_action_t *get_cfg_crt_action(void);
72 72
 int get_cfg_crt_line(void);
73 73
 char *get_cfg_crt_name(void);
74 74
 
75
+void set_max_recursive_level(unsigned int lev);
76
+
75 77
 #ifdef USE_LONGJMP
76 78
 int run_actions_safe(struct run_act_ctx* c, struct action* a,
77 79
 						struct sip_msg* msg);
... ...
@@ -482,6 +482,8 @@ VERSION_TABLE_CFG		"version_table"
482 482
 
483 483
 SERVER_ID     "server_id"
484 484
 
485
+MAX_RECURSIVE_LEVEL		"max_recursive_level"
486
+
485 487
 LATENCY_LOG				latency_log
486 488
 LATENCY_LIMIT_DB		latency_limit_db
487 489
 LATENCY_LIMIT_ACTION	latency_limit_action
... ...
@@ -917,6 +919,7 @@ IMPORTFILE      "import_file"
917 917
 									return HTTP_REPLY_PARSE; }
918 918
 <INITIAL>{VERSION_TABLE_CFG}  { count(); yylval.strval=yytext; return VERSION_TABLE_CFG;}
919 919
 <INITIAL>{SERVER_ID}  { count(); yylval.strval=yytext; return SERVER_ID;}
920
+<INITIAL>{MAX_RECURSIVE_LEVEL}  { count(); yylval.strval=yytext; return MAX_RECURSIVE_LEVEL;}
920 921
 <INITIAL>{LATENCY_LOG}  { count(); yylval.strval=yytext; return LATENCY_LOG;}
921 922
 <INITIAL>{MSG_TIME}  { count(); yylval.strval=yytext; return MSG_TIME;}
922 923
 <INITIAL>{LATENCY_LIMIT_DB}  { count(); yylval.strval=yytext; return LATENCY_LIMIT_DB;}
... ...
@@ -536,6 +536,7 @@ extern char *finame;
536 536
 %token VERSION_TABLE_CFG
537 537
 %token CFG_DESCRIPTION
538 538
 %token SERVER_ID
539
+%token MAX_RECURSIVE_LEVEL
539 540
 %token LATENCY_LOG
540 541
 %token LATENCY_LIMIT_DB
541 542
 %token LATENCY_LIMIT_ACTION
... ...
@@ -1559,6 +1560,7 @@ assign_stm:
1559 1559
 	| HTTP_REPLY_PARSE EQUAL NUMBER { http_reply_parse=$3; }
1560 1560
 	| HTTP_REPLY_PARSE EQUAL error { yyerror("boolean value expected"); }
1561 1561
     | SERVER_ID EQUAL NUMBER { server_id=$3; }
1562
+    | MAX_RECURSIVE_LEVEL EQUAL NUMBER { set_max_recursive_level($3); }
1562 1563
     | LATENCY_LOG EQUAL NUMBER { default_core_cfg.latency_log=$3; }
1563 1564
 	| LATENCY_LOG EQUAL error  { yyerror("number  expected"); }
1564 1565
     | LATENCY_LIMIT_DB EQUAL NUMBER { default_core_cfg.latency_limit_db=$3; }
... ...
@@ -66,9 +66,6 @@
66 66
 #define EVENT_RT_NO RT_NO 		/*!< event_route routing tables number */
67 67
 #define DEFAULT_RT 0 			/*!< default routing table */
68 68
 
69
-#define MAX_REC_LEV 100 		/*!< maximum number of recursive calls */
70
-#define ROUTE_MAX_REC_LEV 100 		/*!< maximum number of recursive calls for route()*/
71
-
72 69
 #define MAX_URI_SIZE 1024		/*!< Max URI size used when rewriting URIs */
73 70
 
74 71
 #define MAX_PATH_SIZE 256 		/*!< Maximum length of path header buffer */