[sr-dev] git:kamailio_3.0: ctl: added parameters to control buffer size

Daniel-Constantin Mierla miconda at gmail.com
Sun Jan 10 20:02:38 CET 2010


Module: sip-router
Branch: kamailio_3.0
Commit: acfc2142ed5ef3e61138792136eb32616502229d
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=acfc2142ed5ef3e61138792136eb32616502229d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Sun Jan 10 16:56:54 2010 +0100

ctl: added parameters to control buffer size

- new parameters to control binrpc buffers size:
- binrpc_max_body_size
- binrpc_struct_max_body_size

---

 modules/ctl/README         |   28 +++++++++++++++++++++++++---
 modules/ctl/binrpc_run.c   |    7 ++++---
 modules/ctl/ctl.c          |   13 ++++++++++++-
 modules/ctl/doc/params.xml |   36 ++++++++++++++++++++++++++++++++++++
 4 files changed, 77 insertions(+), 7 deletions(-)

diff --git a/modules/ctl/README b/modules/ctl/README
index 12850b3..7b5c876 100644
--- a/modules/ctl/README
+++ b/modules/ctl/README
@@ -19,6 +19,8 @@ Andrei Pelinescu-Onciul
         1.3.4. group (integer or string)
         1.3.5. fifo (integer)
         1.3.6. autoconversion (integer)
+        1.3.7. binrpc_max_body_size (integer)
+        1.3.8. binrpc_struct_max_body_size (integer)
 
    1.4. RPC Functions
 
@@ -180,6 +182,26 @@ modparam("ctl", "fifo", "tcp:*:2050")              # fifo over tcp
    Example 7. Set the autoconversion parameter
 modparam("ctl", "autoconversion", 1)
 
+1.3.7. binrpc_max_body_size (integer)
+
+   Set the size of binrpc buffer for RPC reply. Value represents
+   kilobytes.
+
+   Default: 4 (meaning 4KB);
+
+   Example 8. Set the binrpc_max_body_size parameter
+modparam("ctl", "binrpc_max_body_size", 10)
+
+1.3.8. binrpc_struct_max_body_size (integer)
+
+   Set the size of binrpc structure buffer for RPC reply. Value represents
+   kilobytes.
+
+   Default: 1 (meaning 1KB);
+
+   Example 9. Set the binrpc_struct_max_body_size parameter
+modparam("ctl", "binrpc_struct_max_body_size", 3)
+
 1.4. RPC Functions
 
    Revision History
@@ -189,7 +211,7 @@ modparam("ctl", "autoconversion", 1)
 
    List all the sockets on which the ctl module listens.
 
-   Example 8. print usage
+   Example 10. print usage
  $ sercmd -f"[%v] %v:%v %v\n" ctl.listen
 [binrpc] unix_stream:/tmp/ser_ctl
 
@@ -199,7 +221,7 @@ modparam("ctl", "autoconversion", 1)
 
    Returns the number of open binrpc connections (to the ctl module).
 
-   Example 9. ctl.connections usage
+   Example 11. ctl.connections usage
  $ sercmd ctl.connections
 1
 
@@ -207,7 +229,7 @@ modparam("ctl", "autoconversion", 1)
 
    List open binrpc connections (to the ctl module).
 
-   Example 10. ctl.who usage
+   Example 12. ctl.who usage
  $ sercmd -f"[%v] %v: %v %v -> %v %v\n" ctl.who
 [binrpc] unix_stream: <anonymous unix socket>  -> /tmp/ser_ctl
 
diff --git a/modules/ctl/binrpc_run.c b/modules/ctl/binrpc_run.c
index 8ad914f..989f889 100644
--- a/modules/ctl/binrpc_run.c
+++ b/modules/ctl/binrpc_run.c
@@ -46,9 +46,10 @@
    rpc->scan (default: not set) */
 int autoconvert=0;
 
-
-#define BINRPC_MAX_BODY	4096  /* maximum body for send */
-#define STRUCT_MAX_BODY	1024
+int binrpc_max_body_size = 4; /* multiplied by 1024 in mod init */
+int  binrpc_struct_max_body_size = 1; /* multiplied by 1024 in mod init */
+#define BINRPC_MAX_BODY	binrpc_max_body_size  /* maximum body for send */
+#define STRUCT_MAX_BODY	binrpc_struct_max_body_size
 #define MAX_MSG_CHUNKS	96
 
 #define BINRPC_GC_IBSIZE 4 /* initial gc block size (pointers no.) */
diff --git a/modules/ctl/ctl.c b/modules/ctl/ctl.c
index 8e50e51..bd675f8 100644
--- a/modules/ctl/ctl.c
+++ b/modules/ctl/ctl.c
@@ -70,6 +70,8 @@ static int usock_gid=-1;
 /* if set try to automatically convert values to the requested type in
    rpc->scan (default: not set) */
 extern int autoconvert; 
+extern int binrpc_max_body_size;
+extern int binrpc_struct_max_body_size;
 
 static int add_binrpc_socket(modparam_t type, void * val);
 #ifdef USE_FIFO
@@ -104,6 +106,8 @@ static param_export_t params[]={
 	{"user",		PARAM_STRING|PARAM_USE_FUNC,	fix_user				 },
 	{"group",		PARAM_STRING|PARAM_USE_FUNC,	fix_group				 },
 	{"autoconversion",	PARAM_INT,					&autoconvert			 },
+	{"binrpc_max_body_size",        PARAM_INT, &binrpc_max_body_size         },
+	{"binrpc_struct_max_body_size", PARAM_INT, &binrpc_struct_max_body_size  },
 	{0,0,0} 
 }; /* no params */
 
@@ -224,7 +228,14 @@ error:
 static int mod_init(void)
 {
 	struct id_list* l;
-	
+
+	if(binrpc_max_body_size<=0)
+		binrpc_max_body_size = 4;
+	if(binrpc_struct_max_body_size<=0)
+		binrpc_struct_max_body_size = 1;
+	binrpc_max_body_size *= 1024;
+	binrpc_struct_max_body_size *= 1024;
+
 	if (listen_lst==0) {
 		add_binrpc_socket(PARAM_STRING, DEFAULT_CTL_SOCKET);
 	}
diff --git a/modules/ctl/doc/params.xml b/modules/ctl/doc/params.xml
index c2b06c2..a61e013 100644
--- a/modules/ctl/doc/params.xml
+++ b/modules/ctl/doc/params.xml
@@ -192,4 +192,40 @@ modparam("ctl", "autoconversion", 1)
 	</example>
 	</section>
 
+	<section id="binrpc_max_body_size">
+	<title><varname>binrpc_max_body_size</varname> (integer)</title>
+	<para>
+		Set the size of binrpc buffer for RPC reply. Value represents
+		kilobytes.
+	</para>
+	<para>
+		Default: 4 (meaning 4KB);
+	</para>
+	<example>
+		<title>Set the <varname>binrpc_max_body_size</varname> parameter
+		</title>
+		<programlisting>
+modparam("ctl", "binrpc_max_body_size", 10)
+		</programlisting>
+	</example>
+	</section>
+
+	<section id="binrpc_struct_max_body_size">
+	<title><varname>binrpc_struct_max_body_size</varname> (integer)</title>
+	<para>
+		Set the size of binrpc structure buffer for RPC reply. Value represents
+		kilobytes.
+	</para>
+	<para>
+		Default: 1 (meaning 1KB);
+	</para>
+	<example>
+		<title>Set the <varname>binrpc_struct_max_body_size</varname> parameter
+		</title>
+		<programlisting>
+modparam("ctl", "binrpc_struct_max_body_size", 3)
+		</programlisting>
+	</example>
+	</section>
+
 </section>




More information about the sr-dev mailing list