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 224
 {
225 225
 	int v;
226 226
 	v=(int)(long)*val;
227
+#ifdef USE_TCP
227 228
 	if (v>tcp_max_connections){
228 229
 		INFO("cannot override hard tcp_max_connections limit, please"
229 230
 				" restart and increase tcp_max_connections in the cfg.\n");
230 231
 		v=tcp_max_connections;
231 232
 	}
233
+#else /* USE_TCP */
234
+	if (v){
235
+		ERR("TCP support disabled at compile-time, tcp_max_connection is"
236
+				" hardwired to 0.\n");
237
+		v=0;
238
+	}
239
+#endif /*USE_TCP */
232 240
 	*val=(void*)(long)v;
233 241
 	return 0;
234 242
 }
... ...
@@ -325,7 +337,11 @@ void tcp_options_check()
325 325
 						MAX_TCP_CON_LIFETIME);
326 326
 	fix_timeout("tcp_connection_lifetime", &tcp_default_cfg.con_lifetime,
327 327
 						MAX_TCP_CON_LIFETIME, MAX_TCP_CON_LIFETIME);
328
+#ifdef USE_TCP
328 329
 	tcp_default_cfg.max_connections=tcp_max_connections;
330
+#else /* USE_TCP */
331
+	tcp_default_cfg.max_connections=0;
332
+#endif /* USE_TCP */
329 333
 	tcp_cfg_def_fix("rd_buf_size", (int*)&tcp_default_cfg.rd_buf_size);
330 334
 	tcp_cfg_def_fix("wq_blk_size", (int*)&tcp_default_cfg.wq_blk_size);
331 335
 }