Browse code

tcp: compile fix if -DUSE_TCP is not defined

Don't try to use tcp_max_connections if tcp support is not
compiled-in.

Andrei Pelinescu-Onciul authored on 28/06/2009 09:23:02
Showing 1 changed files
... ...
@@ -121,7 +121,11 @@ void init_tcp_options()
121 121
 	tcp_default_cfg.connect_timeout_s=DEFAULT_TCP_CONNECT_TIMEOUT;
122 122
 	tcp_default_cfg.send_timeout=S_TO_TICKS(DEFAULT_TCP_SEND_TIMEOUT);
123 123
 	tcp_default_cfg.con_lifetime=S_TO_TICKS(DEFAULT_TCP_CONNECTION_LIFETIME_S);
124
+#ifdef USE_TCP
124 125
 	tcp_default_cfg.max_connections=tcp_max_connections;
126
+#else /*USE_TCP*/
127
+	tcp_default_cfg.max_connections=0;
128
+#endif /*USE_TCP*/
125 129
 #ifdef TCP_ASYNC
126 130
 	tcp_default_cfg.async=1;
127 131
 	tcp_default_cfg.tcpconn_wq_max=32*1024; /* 32 k */
... ...
@@ -224,11 +228,19 @@ static int fix_max_conns(void* cfg_h, str* gname, str* name, void** val)
224 228
 {
225 229
 	int v;
226 230
 	v=(int)(long)*val;
231
+#ifdef USE_TCP
227 232
 	if (v>tcp_max_connections){
228 233
 		INFO("cannot override hard tcp_max_connections limit, please"
229 234
 				" restart and increase tcp_max_connections in the cfg.\n");
230 235
 		v=tcp_max_connections;
231 236
 	}
237
+#else /* USE_TCP */
238
+	if (v){
239
+		ERR("TCP support disabled at compile-time, tcp_max_connection is"
240
+				" hardwired to 0.\n");
241
+		v=0;
242
+	}
243
+#endif /*USE_TCP */
232 244
 	*val=(void*)(long)v;
233 245
 	return 0;
234 246
 }
... ...
@@ -325,7 +337,11 @@ void tcp_options_check()
325 337
 						MAX_TCP_CON_LIFETIME);
326 338
 	fix_timeout("tcp_connection_lifetime", &tcp_default_cfg.con_lifetime,
327 339
 						MAX_TCP_CON_LIFETIME, MAX_TCP_CON_LIFETIME);
340
+#ifdef USE_TCP
328 341
 	tcp_default_cfg.max_connections=tcp_max_connections;
342
+#else /* USE_TCP */
343
+	tcp_default_cfg.max_connections=0;
344
+#endif /* USE_TCP */
329 345
 	tcp_cfg_def_fix("rd_buf_size", (int*)&tcp_default_cfg.rd_buf_size);
330 346
 	tcp_cfg_def_fix("wq_blk_size", (int*)&tcp_default_cfg.wq_blk_size);
331 347
 }