Browse code

core: shm mem size can now be set in the config script

shm mem size can now be set in the cfg script using
shm=size_in_mb, shm_mem=size_in_mb or shm_mem_size=size_in_mb.
It must be set prior to any modparam or route block.
Specifying the memory size on the command line (-m size_in_mb)
will override the size from the config file.

Andrei Pelinescu-Onciul authored on 10/01/2010 12:10:43
Showing 3 changed files
... ...
@@ -80,6 +80,7 @@
80 80
  *  2009-03-10  added SET_USERPHONE action (Miklos)
81 81
  *  2009-04-24  add strlen, strempty and defined operators (andrei)
82 82
  *  2009-03-07  RETCODE, it's now  a core pvar (andrei)
83
+ *  2010-01-10  added SHM_MEM_SZ (andrei)
83 84
 */
84 85
 
85 86
 
... ...
@@ -430,6 +431,7 @@ ADVERTISED_ADDRESS	"advertised_address"
430 430
 ADVERTISED_PORT		"advertised_port"
431 431
 DISABLE_CORE		"disable_core_dump"
432 432
 OPEN_FD_LIMIT		"open_files_limit"
433
+SHM_MEM_SZ		"shm"|"shm_mem"|"shm_mem_size"
433 434
 SHM_FORCE_ALLOC		"shm_force_alloc"
434 435
 MLOCK_PAGES			"mlock_pages"
435 436
 REAL_TIME			"real_time"
... ...
@@ -818,6 +820,8 @@ EAT_ABLE	[\ \t\b\r]
818 818
 									return DISABLE_CORE; }
819 819
 <INITIAL>{OPEN_FD_LIMIT}		{	count(); yylval.strval=yytext;
820 820
 									return OPEN_FD_LIMIT; }
821
+<INITIAL>{SHM_MEM_SZ}		{	count(); yylval.strval=yytext;
822
+									return SHM_MEM_SZ; }
821 823
 <INITIAL>{SHM_FORCE_ALLOC}		{	count(); yylval.strval=yytext;
822 824
 									return SHM_FORCE_ALLOC; }
823 825
 <INITIAL>{MLOCK_PAGES}		{	count(); yylval.strval=yytext;
... ...
@@ -96,7 +96,8 @@
96 96
  * 2009-01-26  case/switch() support (andrei)
97 97
  * 2009-03-10  added SET_USERPHONE action (Miklos)
98 98
  * 2009-05-04  switched if to rval_expr (andrei)
99
- * 2010-01-10  init shm on first mod_param or route block (andrei)
99
+ * 2010-01-10  init shm on first mod_param or route block;
100
+ *             added SHM_MEM_SZ (andrei)
100 101
 */
101 102
 
102 103
 %{
... ...
@@ -494,6 +495,7 @@ extern char *finame;
494 494
 %token ADVERTISED_PORT
495 495
 %token DISABLE_CORE
496 496
 %token OPEN_FD_LIMIT
497
+%token SHM_MEM_SZ
497 498
 %token SHM_FORCE_ALLOC
498 499
 %token MLOCK_PAGES
499 500
 %token REAL_TIME
... ...
@@ -1463,6 +1465,14 @@ assign_stm:
1463 1463
 	| DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
1464 1464
 	| OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
1465 1465
 	| OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
1466
+	| SHM_MEM_SZ EQUAL NUMBER {
1467
+		if (shm_initialized())
1468
+			yyerror("shm/shm_mem_size must be before any modparam or the"
1469
+					" route blocks");
1470
+		else if (shm_mem_size == 0)
1471
+			shm_mem_size=$3 * 1024 * 1024;
1472
+	}
1473
+	| SHM_MEM_SZ EQUAL error { yyerror("number expected"); }
1466 1474
 	| SHM_FORCE_ALLOC EQUAL NUMBER {
1467 1475
 		if (shm_initialized())
1468 1476
 			yyerror("shm_force_alloc must be before any modparam or the"
... ...
@@ -469,7 +469,7 @@ int cfg_warnings=0;
469 469
 
470 470
 
471 471
 /* shared memory (in MB) */
472
-unsigned long shm_mem_size=SHM_MEM_SIZE * 1024 * 1024;
472
+unsigned long shm_mem_size=0;
473 473
 
474 474
 /* export command-line to anywhere else */
475 475
 int my_argc;