[sr-dev] git:master: core/tcp: proper init of parameter tls_max_connections

Daniel-Constantin Mierla miconda at gmail.com
Tue Dec 20 09:21:46 CET 2011


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Tue Dec 20 00:33:39 2011 +0100

core/tcp: proper init of parameter tls_max_connections

- the fixup function was setting to tcp value

---

 tcp_options.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/tcp_options.c b/tcp_options.c
index dc5df93..2705d5b 100644
--- a/tcp_options.c
+++ b/tcp_options.c
@@ -51,6 +51,7 @@ static int fix_connect_to(void* cfg_h, str* gname, str* name, void** val);
 static int fix_send_to(void* cfg_h, str* gname, str* name, void** val);
 static int fix_con_lt(void* cfg_h, str* gname, str* name, void** val);
 static int fix_max_conns(void* cfg_h, str* gname, str* name, void** val);
+static int fix_max_tls_conns(void* cfg_h, str* gname, str* name, void** val);
 
 
 
@@ -71,7 +72,7 @@ static cfg_def_t tcp_cfg_def[] = {
 													       fix_max_conns,    0,
 		"maximum tcp connections number, soft limit"},
 	{ "max_tls_connections", CFG_VAR_INT | CFG_ATOMIC, 0, (1U<<31)-1,
-													       fix_max_conns,    0,
+													       fix_max_tls_conns,0,
 		"maximum tls connections number, soft limit"},
 	{ "no_connect",   CFG_VAR_INT | CFG_ATOMIC,      0,   1,      0,         0,
 		"if set only accept new connections, never actively open new ones"},
@@ -138,6 +139,7 @@ void init_tcp_options()
 	tcp_default_cfg.max_tls_connections=tls_max_connections;
 #else /*USE_TCP*/
 	tcp_default_cfg.max_connections=0;
+	tcp_default_cfg.max_tls_connections=0;
 #endif /*USE_TCP*/
 #ifdef TCP_ASYNC
 	tcp_default_cfg.async=1;
@@ -258,6 +260,27 @@ static int fix_max_conns(void* cfg_h, str* gname, str* name, void** val)
 	return 0;
 }
 
+static int fix_max_tls_conns(void* cfg_h, str* gname, str* name, void** val)
+{
+	int v;
+	v=(int)(long)*val;
+#ifdef USE_TLS
+	if (v>tls_max_connections){
+		INFO("cannot override hard tls_max_connections limit, please"
+				" restart and increase tls_max_connections in the cfg.\n");
+		v=tls_max_connections;
+	}
+#else /* USE_TLS */
+	if (v){
+		ERR("TLS support disabled at compile-time, tls_max_connection is"
+				" hardwired to 0.\n");
+		v=0;
+	}
+#endif /*USE_TLS */
+	*val=(void*)(long)v;
+	return 0;
+}
+
 
 
 /** fix *val according to the cfg entry "name".




More information about the sr-dev mailing list