[sr-dev] git:master: core: control pv buffer size by core parameters

Daniel-Constantin Mierla miconda at gmail.com
Fri Jul 15 22:56:01 CEST 2011


Module: sip-router
Branch: master
Commit: 7614a1d0322c930b81009675e78c2439b76a29d1
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7614a1d0322c930b81009675e78c2439b76a29d1

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri Jul 15 21:55:33 2011 +0200

core: control pv buffer size by core parameters

- pv_buffer_size - size in bytes for internal PV buffer (default 1024)
- pv_buffer_slots - home many internal PV buffers (default 10)

---

 cfg.lex |    6 ++++++
 cfg.y   |    7 +++++++
 pvapi.c |    4 +++-
 3 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/cfg.lex b/cfg.lex
index dd67ea8..e800696 100644
--- a/cfg.lex
+++ b/cfg.lex
@@ -483,6 +483,8 @@ TOS			"tos"
 PMTU_DISCOVERY	"pmtu_discovery"
 KILL_TIMEOUT	"exit_timeout"|"ser_kill_timeout"
 MAX_WLOOPS		"max_while_loops"
+PVBUFSIZE		"pv_buffer_size"
+PVBUFSLOTS		"pv_buffer_slots"
 
 /* stun config variables */
 STUN_REFRESH_INTERVAL "stun_refresh_interval"
@@ -933,6 +935,10 @@ IMPORTFILE      "import_file"
 									return KILL_TIMEOUT; }
 <INITIAL>{MAX_WLOOPS}			{	count(); yylval.strval=yytext;
 									return MAX_WLOOPS; }
+<INITIAL>{PVBUFSIZE}			{	count(); yylval.strval=yytext;
+									return PVBUFSIZE; }
+<INITIAL>{PVBUFSLOTS}			{	count(); yylval.strval=yytext;
+									return PVBUFSLOTS; }
 <INITIAL>{SERVER_ID}  { count(); yylval.strval=yytext; return SERVER_ID;}
 <INITIAL>{CFG_DESCRIPTION}	{ count(); yylval.strval=yytext; return CFG_DESCRIPTION; }
 <INITIAL>{LOADMODULE}	{ count(); yylval.strval=yytext; return LOADMODULE; }
diff --git a/cfg.y b/cfg.y
index b0e18bc..49bce54 100644
--- a/cfg.y
+++ b/cfg.y
@@ -142,6 +142,7 @@
 #include "msg_translator.h"
 
 #include "ppcfg.h"
+#include "pvapi.h"
 #include "config.h"
 #include "cfg_core.h"
 #include "cfg/cfg.h"
@@ -536,6 +537,8 @@ extern char *finame;
 %token PMTU_DISCOVERY
 %token KILL_TIMEOUT
 %token MAX_WLOOPS
+%token PVBUFSIZE
+%token PVBUFSLOTS
 %token CFG_DESCRIPTION
 %token SERVER_ID
 
@@ -1586,6 +1589,10 @@ assign_stm:
 	| KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
 	| MAX_WLOOPS EQUAL NUMBER { default_core_cfg.max_while_loops=$3; }
 	| MAX_WLOOPS EQUAL error { yyerror("number expected"); }
+	| PVBUFSIZE EQUAL NUMBER { pv_set_buffer_size($3); }
+	| PVBUFSIZE EQUAL error { yyerror("number expected"); }
+	| PVBUFSLOTS EQUAL NUMBER { pv_set_buffer_slots($3); }
+	| PVBUFSLOTS EQUAL error { yyerror("number expected"); }
 	| STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
 	| STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
 	| STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
diff --git a/pvapi.c b/pvapi.c
index 8577bf1..76601a9 100644
--- a/pvapi.c
+++ b/pvapi.c
@@ -1628,7 +1628,7 @@ int pv_init_buffer(void)
 		LM_ERR("cannot init PV print buffer slots\n");
 		return -1;
 	}
-	memset(_pv_print_buffer, 0, _pv_print_buffer_slots);
+	memset(_pv_print_buffer, 0, _pv_print_buffer_slots*sizeof(char*));
 	for(i=0; i<_pv_print_buffer_slots; i++)
 	{
 		_pv_print_buffer[i] =
@@ -1639,6 +1639,8 @@ int pv_init_buffer(void)
 			return -1;
 		}
 	}
+	LM_DBG("PV print buffer initialized to [%d][%d]\n",
+			_pv_print_buffer_slots, _pv_print_buffer_size);
 	return 0;
 }
 




More information about the sr-dev mailing list