Ver Fonte

ctl: added parameters to control buffer size

- new parameters to control binrpc buffers size:
- binrpc_max_body_size
- binrpc_struct_max_body_size
Daniel-Constantin Mierla há 15 anos atrás
pai
commit
acfc2142ed
4 ficheiros alterados com 77 adições e 7 exclusões
  1. 25 3
      modules/ctl/README
  2. 4 3
      modules/ctl/binrpc_run.c
  3. 12 1
      modules/ctl/ctl.c
  4. 36 0
      modules/ctl/doc/params.xml

+ 25 - 3
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
 

+ 4 - 3
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.) */

+ 12 - 1
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);
 	}

+ 36 - 0
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>