Browse code

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)

Daniel-Constantin Mierla authored on 15/07/2011 19:55:33
Showing 3 changed files
... ...
@@ -483,6 +483,8 @@ TOS			"tos"
483 483
 PMTU_DISCOVERY	"pmtu_discovery"
484 484
 KILL_TIMEOUT	"exit_timeout"|"ser_kill_timeout"
485 485
 MAX_WLOOPS		"max_while_loops"
486
+PVBUFSIZE		"pv_buffer_size"
487
+PVBUFSLOTS		"pv_buffer_slots"
486 488
 
487 489
 /* stun config variables */
488 490
 STUN_REFRESH_INTERVAL "stun_refresh_interval"
... ...
@@ -933,6 +935,10 @@ IMPORTFILE      "import_file"
933 933
 									return KILL_TIMEOUT; }
934 934
 <INITIAL>{MAX_WLOOPS}			{	count(); yylval.strval=yytext;
935 935
 									return MAX_WLOOPS; }
936
+<INITIAL>{PVBUFSIZE}			{	count(); yylval.strval=yytext;
937
+									return PVBUFSIZE; }
938
+<INITIAL>{PVBUFSLOTS}			{	count(); yylval.strval=yytext;
939
+									return PVBUFSLOTS; }
936 940
 <INITIAL>{SERVER_ID}  { count(); yylval.strval=yytext; return SERVER_ID;}
937 941
 <INITIAL>{CFG_DESCRIPTION}	{ count(); yylval.strval=yytext; return CFG_DESCRIPTION; }
938 942
 <INITIAL>{LOADMODULE}	{ count(); yylval.strval=yytext; return LOADMODULE; }
... ...
@@ -142,6 +142,7 @@
142 142
 #include "msg_translator.h"
143 143
 
144 144
 #include "ppcfg.h"
145
+#include "pvapi.h"
145 146
 #include "config.h"
146 147
 #include "cfg_core.h"
147 148
 #include "cfg/cfg.h"
... ...
@@ -536,6 +537,8 @@ extern char *finame;
536 536
 %token PMTU_DISCOVERY
537 537
 %token KILL_TIMEOUT
538 538
 %token MAX_WLOOPS
539
+%token PVBUFSIZE
540
+%token PVBUFSLOTS
539 541
 %token CFG_DESCRIPTION
540 542
 %token SERVER_ID
541 543
 
... ...
@@ -1586,6 +1589,10 @@ assign_stm:
1586 1586
 	| KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
1587 1587
 	| MAX_WLOOPS EQUAL NUMBER { default_core_cfg.max_while_loops=$3; }
1588 1588
 	| MAX_WLOOPS EQUAL error { yyerror("number expected"); }
1589
+	| PVBUFSIZE EQUAL NUMBER { pv_set_buffer_size($3); }
1590
+	| PVBUFSIZE EQUAL error { yyerror("number expected"); }
1591
+	| PVBUFSLOTS EQUAL NUMBER { pv_set_buffer_slots($3); }
1592
+	| PVBUFSLOTS EQUAL error { yyerror("number expected"); }
1589 1593
 	| STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
1590 1594
 	| STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
1591 1595
 	| STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
... ...
@@ -1628,7 +1628,7 @@ int pv_init_buffer(void)
1628 1628
 		LM_ERR("cannot init PV print buffer slots\n");
1629 1629
 		return -1;
1630 1630
 	}
1631
-	memset(_pv_print_buffer, 0, _pv_print_buffer_slots);
1631
+	memset(_pv_print_buffer, 0, _pv_print_buffer_slots*sizeof(char*));
1632 1632
 	for(i=0; i<_pv_print_buffer_slots; i++)
1633 1633
 	{
1634 1634
 		_pv_print_buffer[i] =
... ...
@@ -1639,6 +1639,8 @@ int pv_init_buffer(void)
1639 1639
 			return -1;
1640 1640
 		}
1641 1641
 	}
1642
+	LM_DBG("PV print buffer initialized to [%d][%d]\n",
1643
+			_pv_print_buffer_slots, _pv_print_buffer_size);
1642 1644
 	return 0;
1643 1645
 }
1644 1646