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 72
 													       fix_max_conns,    0,
72 73
 		"maximum tcp connections number, soft limit"},
73 74
 	{ "max_tls_connections", CFG_VAR_INT | CFG_ATOMIC, 0, (1U<<31)-1,
74
-													       fix_max_conns,    0,
75
+													       fix_max_tls_conns,0,
75 76
 		"maximum tls connections number, soft limit"},
76 77
 	{ "no_connect",   CFG_VAR_INT | CFG_ATOMIC,      0,   1,      0,         0,
77 78
 		"if set only accept new connections, never actively open new ones"},
... ...
@@ -138,6 +139,7 @@ void init_tcp_options()
138 139
 	tcp_default_cfg.max_tls_connections=tls_max_connections;
139 140
 #else /*USE_TCP*/
140 141
 	tcp_default_cfg.max_connections=0;
142
+	tcp_default_cfg.max_tls_connections=0;
141 143
 #endif /*USE_TCP*/
142 144
 #ifdef TCP_ASYNC
143 145
 	tcp_default_cfg.async=1;
... ...
@@ -258,6 +260,27 @@ static int fix_max_conns(void* cfg_h, str* gname, str* name, void** val)
258 260
 	return 0;
259 261
 }
260 262
 
263
+static int fix_max_tls_conns(void* cfg_h, str* gname, str* name, void** val)
264
+{
265
+	int v;
266
+	v=(int)(long)*val;
267
+#ifdef USE_TLS
268
+	if (v>tls_max_connections){
269
+		INFO("cannot override hard tls_max_connections limit, please"
270
+				" restart and increase tls_max_connections in the cfg.\n");
271
+		v=tls_max_connections;
272
+	}
273
+#else /* USE_TLS */
274
+	if (v){
275
+		ERR("TLS support disabled at compile-time, tls_max_connection is"
276
+				" hardwired to 0.\n");
277
+		v=0;
278
+	}
279
+#endif /*USE_TLS */
280
+	*val=(void*)(long)v;
281
+	return 0;
282
+}
283
+
261 284
 
262 285
 
263 286
 /** fix *val according to the cfg entry "name".