Browse code

core/tcp: proper init of parameter tls_max_connections

- the fixup function was setting to tcp value

Daniel-Constantin Mierla authored on 19/12/2011 23:33:39
Showing 1 changed files
... ...
@@ -51,6 +51,7 @@ static int fix_connect_to(void* cfg_h, str* gname, str* name, void** val);
51 51
 static int fix_send_to(void* cfg_h, str* gname, str* name, void** val);
52 52
 static int fix_con_lt(void* cfg_h, str* gname, str* name, void** val);
53 53
 static int fix_max_conns(void* cfg_h, str* gname, str* name, void** val);
54
+static int fix_max_tls_conns(void* cfg_h, str* gname, str* name, void** val);
54 55
 
55 56
 
56 57
 
... ...
@@ -71,7 +72,7 @@ static cfg_def_t tcp_cfg_def[] = {
71 71
 													       fix_max_conns,    0,
72 72
 		"maximum tcp connections number, soft limit"},
73 73
 	{ "max_tls_connections", CFG_VAR_INT | CFG_ATOMIC, 0, (1U<<31)-1,
74
-													       fix_max_conns,    0,
74
+													       fix_max_tls_conns,0,
75 75
 		"maximum tls connections number, soft limit"},
76 76
 	{ "no_connect",   CFG_VAR_INT | CFG_ATOMIC,      0,   1,      0,         0,
77 77
 		"if set only accept new connections, never actively open new ones"},
... ...
@@ -138,6 +139,7 @@ void init_tcp_options()
138 138
 	tcp_default_cfg.max_tls_connections=tls_max_connections;
139 139
 #else /*USE_TCP*/
140 140
 	tcp_default_cfg.max_connections=0;
141
+	tcp_default_cfg.max_tls_connections=0;
141 142
 #endif /*USE_TCP*/
142 143
 #ifdef TCP_ASYNC
143 144
 	tcp_default_cfg.async=1;
... ...
@@ -258,6 +260,27 @@ static int fix_max_conns(void* cfg_h, str* gname, str* name, void** val)
258 258
 	return 0;
259 259
 }
260 260
 
261
+static int fix_max_tls_conns(void* cfg_h, str* gname, str* name, void** val)
262
+{
263
+	int v;
264
+	v=(int)(long)*val;
265
+#ifdef USE_TLS
266
+	if (v>tls_max_connections){
267
+		INFO("cannot override hard tls_max_connections limit, please"
268
+				" restart and increase tls_max_connections in the cfg.\n");
269
+		v=tls_max_connections;
270
+	}
271
+#else /* USE_TLS */
272
+	if (v){
273
+		ERR("TLS support disabled at compile-time, tls_max_connection is"
274
+				" hardwired to 0.\n");
275
+		v=0;
276
+	}
277
+#endif /*USE_TLS */
278
+	*val=(void*)(long)v;
279
+	return 0;
280
+}
281
+
261 282
 
262 283
 
263 284
 /** fix *val according to the cfg entry "name".