Module: sip-router
Branch: kamailio_3.0
Commit: ecc3fd3f0599cf9fa1bb070970d730f4ab85675e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ecc3fd3…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sun Jan 10 13:10:43 2010 +0100
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.
(cherry picked from commit 647cc9832560590adc6e20685c2d53350a932fb2)
---
cfg.lex | 4 ++++
cfg.y | 12 +++++++++++-
main.c | 2 +-
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/cfg.lex b/cfg.lex
index e63cebf..3d41477 100644
--- a/cfg.lex
+++ b/cfg.lex
@@ -80,6 +80,7 @@
* 2009-03-10 added SET_USERPHONE action (Miklos)
* 2009-04-24 add strlen, strempty and defined operators (andrei)
* 2009-03-07 RETCODE, it's now a core pvar (andrei)
+ * 2010-01-10 added SHM_MEM_SZ (andrei)
*/
@@ -444,6 +445,7 @@ ADVERTISED_ADDRESS "advertised_address"
ADVERTISED_PORT "advertised_port"
DISABLE_CORE "disable_core_dump"
OPEN_FD_LIMIT "open_files_limit"
+SHM_MEM_SZ "shm"|"shm_mem"|"shm_mem_size"
SHM_FORCE_ALLOC "shm_force_alloc"
MLOCK_PAGES "mlock_pages"
REAL_TIME "real_time"
@@ -839,6 +841,8 @@ EAT_ABLE [\ \t\b\r]
return DISABLE_CORE; }
<INITIAL>{OPEN_FD_LIMIT} { count(); yylval.strval=yytext;
return OPEN_FD_LIMIT; }
+<INITIAL>{SHM_MEM_SZ} { count(); yylval.strval=yytext;
+ return SHM_MEM_SZ; }
<INITIAL>{SHM_FORCE_ALLOC} { count(); yylval.strval=yytext;
return SHM_FORCE_ALLOC; }
<INITIAL>{MLOCK_PAGES} { count(); yylval.strval=yytext;
diff --git a/cfg.y b/cfg.y
index bbd5ad3..9266e2e 100644
--- a/cfg.y
+++ b/cfg.y
@@ -96,7 +96,8 @@
* 2009-01-26 case/switch() support (andrei)
* 2009-03-10 added SET_USERPHONE action (Miklos)
* 2009-05-04 switched if to rval_expr (andrei)
- * 2010-01-10 init shm on first mod_param or route block (andrei)
+ * 2010-01-10 init shm on first mod_param or route block;
+ * added SHM_MEM_SZ (andrei)
*/
%{
@@ -494,6 +495,7 @@ extern char *finame;
%token ADVERTISED_PORT
%token DISABLE_CORE
%token OPEN_FD_LIMIT
+%token SHM_MEM_SZ
%token SHM_FORCE_ALLOC
%token MLOCK_PAGES
%token REAL_TIME
@@ -1463,6 +1465,14 @@ assign_stm:
| DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
| OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
| OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
+ | SHM_MEM_SZ EQUAL NUMBER {
+ if (shm_initialized())
+ yyerror("shm/shm_mem_size must be before any modparam or the"
+ " route blocks");
+ else if (shm_mem_size == 0)
+ shm_mem_size=$3 * 1024 * 1024;
+ }
+ | SHM_MEM_SZ EQUAL error { yyerror("number expected"); }
| SHM_FORCE_ALLOC EQUAL NUMBER {
if (shm_initialized())
yyerror("shm_force_alloc must be before any modparam or the"
diff --git a/main.c b/main.c
index 31a4b65..8d0f7e5 100644
--- a/main.c
+++ b/main.c
@@ -469,7 +469,7 @@ int cfg_warnings=0;
/* shared memory (in MB) */
-unsigned long shm_mem_size=SHM_MEM_SIZE * 1024 * 1024;
+unsigned long shm_mem_size=0;
/* export command-line to anywhere else */
int my_argc;