Browse Source

tcp: async mode on by default

- async mode is now on by default (use tcp_async=no in the config
  to disable it)
- renamed tcp_buf_write/TCP_BUF_WRITE into tcp_async/TCP_ASYNC in
  the code
Andrei Pelinescu-Onciul 16 years ago
parent
commit
76cb799e3b
7 changed files with 101 additions and 103 deletions
  1. 2 2
      NEWS
  2. 1 1
      cfg.y
  3. 1 1
      core_cmd.c
  4. 2 2
      tcp_conn.h
  5. 72 72
      tcp_main.c
  6. 14 16
      tcp_options.c
  7. 9 9
      tcp_options.h

+ 2 - 2
NEWS

@@ -273,10 +273,10 @@ new config variables:
      will be cached inside the process calling tcp_send (performance increase
      will be cached inside the process calling tcp_send (performance increase
      for sending over tcp at the cost of slightly slower connection closing and
      for sending over tcp at the cost of slightly slower connection closing and
      extra FDs kept open)
      extra FDs kept open)
-  tcp_async = yes | no (default no) - if enabled all the tcp  writes that 
+  tcp_async = yes | no (default yes) - if enabled all the tcp  writes that 
      would block / wait for connect to finish, will be queued and attempted
      would block / wait for connect to finish, will be queued and attempted
      latter (see also tcp_conn_wq_max and tcp_wq_max).
      latter (see also tcp_conn_wq_max and tcp_wq_max).
-  tcp_buf_write = synonim for tcp_async
+  tcp_buf_write = obsoleted synonim for tcp_async
   tcp_conn_wq_max = bytes (default 32 K) - maximum bytes queued for write 
   tcp_conn_wq_max = bytes (default 32 K) - maximum bytes queued for write 
      allowed per connection. Attempting to queue more bytes would result
      allowed per connection. Attempting to queue more bytes would result
      in an error and in the connection being closed (too slow). If 
      in an error and in the connection being closed (too slow). If 

+ 1 - 1
cfg.y

@@ -873,7 +873,7 @@ assign_stm:
 	| TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
 	| TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
 	| TCP_OPT_BUF_WRITE EQUAL NUMBER {
 	| TCP_OPT_BUF_WRITE EQUAL NUMBER {
 		#ifdef USE_TCP
 		#ifdef USE_TCP
-			tcp_default_cfg.tcp_buf_write=$3;
+			tcp_default_cfg.async=$3;
 		#else
 		#else
 			warn("tcp support not compiled in");
 			warn("tcp support not compiled in");
 		#endif
 		#endif

+ 1 - 1
core_cmd.c

@@ -571,7 +571,7 @@ static void core_tcp_options(rpc_t* rpc, void* c)
 			"connection_lifetime",  t.con_lifetime_s,
 			"connection_lifetime",  t.con_lifetime_s,
 			"max_connections(soft)", t.max_connections,
 			"max_connections(soft)", t.max_connections,
 			"fd_cache",		t.fd_cache,
 			"fd_cache",		t.fd_cache,
-			"async",		t.tcp_buf_write,
+			"async",		t.async,
 			"connect_wait",	t.tcp_connect_wait,
 			"connect_wait",	t.tcp_connect_wait,
 			"conn_wq_max",	t.tcpconn_wq_max,
 			"conn_wq_max",	t.tcpconn_wq_max,
 			"wq_max",		t.tcp_wq_max,
 			"wq_max",		t.tcp_wq_max,

+ 2 - 2
tcp_conn.h

@@ -132,7 +132,7 @@ struct tcp_conn_alias{
 };
 };
 
 
 
 
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	struct tcp_wbuffer{
 	struct tcp_wbuffer{
 		struct tcp_wbuffer* next;
 		struct tcp_wbuffer* next;
 		unsigned int b_size;
 		unsigned int b_size;
@@ -174,7 +174,7 @@ struct tcp_connection{
 	struct tcp_connection* c_prev;
 	struct tcp_connection* c_prev;
 	struct tcp_conn_alias con_aliases[TCP_CON_MAX_ALIASES];
 	struct tcp_conn_alias con_aliases[TCP_CON_MAX_ALIASES];
 	int aliases; /* aliases number, at least 1 */
 	int aliases; /* aliases number, at least 1 */
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	struct tcp_wbuffer_queue wbuf_q;
 	struct tcp_wbuffer_queue wbuf_q;
 #endif
 #endif
 };
 };

+ 72 - 72
tcp_main.c

@@ -207,7 +207,7 @@
 #define TCPCONN_TIMEOUT_MIN_RUN 1  /* once per tick */
 #define TCPCONN_TIMEOUT_MIN_RUN 1  /* once per tick */
 #define TCPCONN_WAIT_TIMEOUT 1 /* 1 tick */
 #define TCPCONN_WAIT_TIMEOUT 1 /* 1 tick */
 
 
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 #define TCP_WBUF_SIZE	1024 /* FIXME: after debugging switch to 16-32k */
 #define TCP_WBUF_SIZE	1024 /* FIXME: after debugging switch to 16-32k */
 static unsigned int* tcp_total_wq=0;
 static unsigned int* tcp_total_wq=0;
 #endif
 #endif
@@ -598,7 +598,7 @@ inline static int _tcpconn_write_nb(int fd, struct tcp_connection* c,
 									char* buf, int len);
 									char* buf, int len);
 
 
 
 
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 
 
 
 
 /* unsafe version */
 /* unsafe version */
@@ -841,7 +841,7 @@ inline static int wbufq_run(int fd, struct tcp_connection* c, int* empty)
 	return ret;
 	return ret;
 }
 }
 
 
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 
 
 
 
 
 
@@ -995,9 +995,9 @@ inline static int tcp_do_connect(	union sockaddr_union* server,
 	union sockaddr_union my_name;
 	union sockaddr_union my_name;
 	socklen_t my_name_len;
 	socklen_t my_name_len;
 	struct ip_addr ip;
 	struct ip_addr ip;
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	int n;
 	int n;
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 
 
 	s=socket(AF2PF(server->s.sa_family), SOCK_STREAM, 0);
 	s=socket(AF2PF(server->s.sa_family), SOCK_STREAM, 0);
 	if (unlikely(s==-1)){
 	if (unlikely(s==-1)){
@@ -1017,8 +1017,8 @@ inline static int tcp_do_connect(	union sockaddr_union* server,
 					strerror(errno), errno);
 					strerror(errno), errno);
 	}
 	}
 	*state=S_CONN_OK;
 	*state=S_CONN_OK;
-#ifdef TCP_BUF_WRITE
-	if (likely(cfg_get(tcp, tcp_cfg, tcp_buf_write))){
+#ifdef TCP_ASYNC
+	if (likely(cfg_get(tcp, tcp_cfg, async))){
 again:
 again:
 		n=connect(s, &server->s, sockaddru_len(*server));
 		n=connect(s, &server->s, sockaddru_len(*server));
 		if (unlikely(n==-1)){
 		if (unlikely(n==-1)){
@@ -1046,16 +1046,16 @@ again:
 			}
 			}
 		}
 		}
 	}else{
 	}else{
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 		if (tcp_blocking_connect(s, type, &server->s,
 		if (tcp_blocking_connect(s, type, &server->s,
 									sockaddru_len(*server))<0){
 									sockaddru_len(*server))<0){
 			LOG(L_ERR, "ERROR: tcp_do_connect: tcp_blocking_connect %s"
 			LOG(L_ERR, "ERROR: tcp_do_connect: tcp_blocking_connect %s"
 						" failed\n", su2a(server, sizeof(*server)));
 						" failed\n", su2a(server, sizeof(*server)));
 			goto error;
 			goto error;
 		}
 		}
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	}
 	}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 	if (from){
 	if (from){
 		su2ip_addr(&ip, from);
 		su2ip_addr(&ip, from);
 		if (!ip_addr_any(&ip))
 		if (!ip_addr_any(&ip))
@@ -1256,7 +1256,7 @@ static inline void _tcpconn_detach(struct tcp_connection *c)
 
 
 static inline void _tcpconn_free(struct tcp_connection* c)
 static inline void _tcpconn_free(struct tcp_connection* c)
 {
 {
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	if (unlikely(_wbufq_non_empty(c)))
 	if (unlikely(_wbufq_non_empty(c)))
 		_wbufq_destroy(&c->wbuf_q);
 		_wbufq_destroy(&c->wbuf_q);
 #endif
 #endif
@@ -1621,9 +1621,9 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
 	int n;
 	int n;
 	int do_close_fd;
 	int do_close_fd;
 	ticks_t con_lifetime;
 	ticks_t con_lifetime;
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	int enable_write_watch;
 	int enable_write_watch;
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 #ifdef TCP_FD_CACHE
 #ifdef TCP_FD_CACHE
 	struct fd_cache_entry* fd_cache_e;
 	struct fd_cache_entry* fd_cache_e;
 	int use_fd_cache;
 	int use_fd_cache;
@@ -1677,9 +1677,9 @@ no_id:
 						break;
 						break;
 				}
 				}
 			}
 			}
-#if defined(TCP_CONNECT_WAIT) && defined(TCP_BUF_WRITE)
+#if defined(TCP_CONNECT_WAIT) && defined(TCP_ASYNC)
 			if (likely(cfg_get(tcp, tcp_cfg, tcp_connect_wait) && 
 			if (likely(cfg_get(tcp, tcp_cfg, tcp_connect_wait) && 
-						cfg_get(tcp, tcp_cfg, tcp_buf_write) )){
+						cfg_get(tcp, tcp_cfg, async) )){
 				if (unlikely(*tcp_connections_no >=
 				if (unlikely(*tcp_connections_no >=
 								cfg_get(tcp, tcp_cfg, max_connections))){
 								cfg_get(tcp, tcp_cfg, max_connections))){
 					LOG(L_ERR, "ERROR: tcp_send %s: maximum number of"
 					LOG(L_ERR, "ERROR: tcp_send %s: maximum number of"
@@ -1795,7 +1795,7 @@ no_id:
 				}
 				}
 				goto end;
 				goto end;
 			}
 			}
-#endif /* TCP_CONNECT_WAIT  && TCP_BUF_WRITE */
+#endif /* TCP_CONNECT_WAIT  && TCP_ASYNC */
 			if (unlikely((c=tcpconn_connect(&dst->to, from, dst->proto))==0)){
 			if (unlikely((c=tcpconn_connect(&dst->to, from, dst->proto))==0)){
 				LOG(L_ERR, "ERROR: tcp_send %s: connect failed\n",
 				LOG(L_ERR, "ERROR: tcp_send %s: connect failed\n",
 								su2a(&dst->to, sizeof(dst->to)));
 								su2a(&dst->to, sizeof(dst->to)));
@@ -1824,9 +1824,9 @@ no_id:
 			goto send_it;
 			goto send_it;
 		}
 		}
 get_fd:
 get_fd:
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 		/* if data is already queued, we don't need the fd any more */
 		/* if data is already queued, we don't need the fd any more */
-		if (unlikely(cfg_get(tcp, tcp_cfg, tcp_buf_write) &&
+		if (unlikely(cfg_get(tcp, tcp_cfg, async) &&
 						(_wbufq_non_empty(c)
 						(_wbufq_non_empty(c)
 #ifdef TCP_CONNECT_WAIT
 #ifdef TCP_CONNECT_WAIT
 												|| (c->state==S_CONN_PENDING)
 												|| (c->state==S_CONN_PENDING)
@@ -1851,7 +1851,7 @@ get_fd:
 				}
 				}
 			lock_release(&c->write_lock);
 			lock_release(&c->write_lock);
 		}
 		}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 		/* check if this is not the same reader process holding
 		/* check if this is not the same reader process holding
 		 *  c  and if so send directly on c->fd */
 		 *  c  and if so send directly on c->fd */
 		if (c->reader_pid==my_pid()){
 		if (c->reader_pid==my_pid()){
@@ -1909,8 +1909,8 @@ get_fd:
 send_it:
 send_it:
 	DBG("tcp_send: sending...\n");
 	DBG("tcp_send: sending...\n");
 	lock_get(&c->write_lock);
 	lock_get(&c->write_lock);
-#ifdef TCP_BUF_WRITE
-	if (likely(cfg_get(tcp, tcp_cfg, tcp_buf_write))){
+#ifdef TCP_ASYNC
+	if (likely(cfg_get(tcp, tcp_cfg, async))){
 		if (_wbufq_non_empty(c)
 		if (_wbufq_non_empty(c)
 #ifdef TCP_CONNECT_WAIT
 #ifdef TCP_CONNECT_WAIT
 			|| (c->state==S_CONN_PENDING) 
 			|| (c->state==S_CONN_PENDING) 
@@ -1927,7 +1927,7 @@ send_it:
 		}
 		}
 		n=_tcpconn_write_nb(fd, c, buf, len);
 		n=_tcpconn_write_nb(fd, c, buf, len);
 	}else{
 	}else{
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 #ifdef USE_TLS
 #ifdef USE_TLS
 	if (c->type==PROTO_TLS)
 	if (c->type==PROTO_TLS)
 		n=tls_blocking_write(c, fd, buf, len);
 		n=tls_blocking_write(c, fd, buf, len);
@@ -1936,17 +1936,17 @@ send_it:
 		/* n=tcp_blocking_write(c, fd, buf, len); */
 		/* n=tcp_blocking_write(c, fd, buf, len); */
 		n=tsend_stream(fd, buf, len,
 		n=tsend_stream(fd, buf, len,
 							cfg_get(tcp, tcp_cfg, send_timeout_s)*1000);
 							cfg_get(tcp, tcp_cfg, send_timeout_s)*1000);
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	}
 	}
-#else /* ! TCP_BUF_WRITE */
+#else /* ! TCP_ASYNC */
 	lock_release(&c->write_lock);
 	lock_release(&c->write_lock);
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 	
 	
 	DBG("tcp_send: after real write: c= %p n=%d fd=%d\n",c, n, fd);
 	DBG("tcp_send: after real write: c= %p n=%d fd=%d\n",c, n, fd);
 	DBG("tcp_send: buf=\n%.*s\n", (int)len, buf);
 	DBG("tcp_send: buf=\n%.*s\n", (int)len, buf);
 	if (unlikely(n<(int)len)){
 	if (unlikely(n<(int)len)){
-#ifdef TCP_BUF_WRITE
-		if (cfg_get(tcp, tcp_cfg, tcp_buf_write) && 
+#ifdef TCP_ASYNC
+		if (cfg_get(tcp, tcp_cfg, async) && 
 				((n>=0) || errno==EAGAIN || errno==EWOULDBLOCK)){
 				((n>=0) || errno==EAGAIN || errno==EWOULDBLOCK)){
 			enable_write_watch=_wbufq_empty(c);
 			enable_write_watch=_wbufq_empty(c);
 			if (n<0) n=0;
 			if (n<0) n=0;
@@ -1971,7 +1971,7 @@ send_it:
 		}else{
 		}else{
 			lock_release(&c->write_lock);
 			lock_release(&c->write_lock);
 		}
 		}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 #ifdef USE_DST_BLACKLIST
 #ifdef USE_DST_BLACKLIST
 		if (cfg_get(core, core_cfg, use_dst_blacklist))
 		if (cfg_get(core, core_cfg, use_dst_blacklist))
 			switch(errno){
 			switch(errno){
@@ -1990,9 +1990,9 @@ send_it:
 					"\n", c, ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port,
 					"\n", c, ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port,
 					su2a(&c->rcv.src_su, sizeof(c->rcv.src_su)),
 					su2a(&c->rcv.src_su, sizeof(c->rcv.src_su)),
 					strerror(errno), errno);
 					strerror(errno), errno);
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 error:
 error:
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 		/* error on the connection , mark it as bad and set 0 timeout */
 		/* error on the connection , mark it as bad and set 0 timeout */
 		c->state=S_CONN_BAD;
 		c->state=S_CONN_BAD;
 		c->timeout=get_ticks_raw();
 		c->timeout=get_ticks_raw();
@@ -2021,13 +2021,13 @@ error:
 		return n; /* error return, no tcpconn_put */
 		return n; /* error return, no tcpconn_put */
 	}
 	}
 	
 	
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	lock_release(&c->write_lock);
 	lock_release(&c->write_lock);
-	if (likely(cfg_get(tcp, tcp_cfg, tcp_buf_write))){
+	if (likely(cfg_get(tcp, tcp_cfg, async))){
 		if (unlikely(c->state==S_CONN_CONNECT))
 		if (unlikely(c->state==S_CONN_CONNECT))
 			c->state=S_CONN_OK;
 			c->state=S_CONN_OK;
 	}
 	}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 end:
 end:
 #ifdef TCP_FD_CACHE
 #ifdef TCP_FD_CACHE
 	if (unlikely((fd_cache_e==0) && use_fd_cache)){
 	if (unlikely((fd_cache_e==0) && use_fd_cache)){
@@ -2368,7 +2368,7 @@ inline static int tcpconn_try_unhash(struct tcp_connection* tcpconn)
 				TCPCONN_UNLOCK;
 				TCPCONN_UNLOCK;
 				return 0;
 				return 0;
 			}
 			}
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 		/* empty possible write buffers (optional) */
 		/* empty possible write buffers (optional) */
 		if (unlikely(_wbufq_non_empty(tcpconn))){
 		if (unlikely(_wbufq_non_empty(tcpconn))){
 			lock_get(&tcpconn->write_lock);
 			lock_get(&tcpconn->write_lock);
@@ -2377,7 +2377,7 @@ inline static int tcpconn_try_unhash(struct tcp_connection* tcpconn)
 					_wbufq_destroy(&tcpconn->wbuf_q);
 					_wbufq_destroy(&tcpconn->wbuf_q);
 			lock_release(&tcpconn->write_lock);
 			lock_release(&tcpconn->write_lock);
 		}
 		}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 		return 1;
 		return 1;
 	}
 	}
 	return 0;
 	return 0;
@@ -2508,7 +2508,7 @@ inline static void send_fd_queue_run(struct tcp_send_fd_q* q)
 						   p->unix_sock, (long)(p-&q->data[0]), p->retries,
 						   p->unix_sock, (long)(p-&q->data[0]), p->retries,
 						   p->tcp_conn, p->tcp_conn->s, errno,
 						   p->tcp_conn, p->tcp_conn->s, errno,
 						   strerror(errno));
 						   strerror(errno));
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 				if (p->tcp_conn->flags & F_CONN_WRITE_W){
 				if (p->tcp_conn->flags & F_CONN_WRITE_W){
 					io_watch_del(&io_h, p->tcp_conn->s, -1, IO_FD_CLOSING);
 					io_watch_del(&io_h, p->tcp_conn->s, -1, IO_FD_CLOSING);
 					p->tcp_conn->flags &=~F_CONN_WRITE_W;
 					p->tcp_conn->flags &=~F_CONN_WRITE_W;
@@ -2642,12 +2642,12 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
 				break;
 				break;
 			}
 			}
 			if (unlikely(tcpconn->state==S_CONN_BAD)){ 
 			if (unlikely(tcpconn->state==S_CONN_BAD)){ 
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 				if (unlikely(tcpconn->flags & F_CONN_WRITE_W)){
 				if (unlikely(tcpconn->flags & F_CONN_WRITE_W)){
 					io_watch_del(&io_h, tcpconn->s, -1, IO_FD_CLOSING);
 					io_watch_del(&io_h, tcpconn->s, -1, IO_FD_CLOSING);
 					tcpconn->flags &= ~F_CONN_WRITE_W;
 					tcpconn->flags &= ~F_CONN_WRITE_W;
 				}
 				}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 				if (tcpconn_try_unhash(tcpconn))
 				if (tcpconn_try_unhash(tcpconn))
 					tcpconn_put_destroy(tcpconn);
 					tcpconn_put_destroy(tcpconn);
 				break;
 				break;
@@ -2657,8 +2657,8 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
 			con_lifetime=cfg_get(tcp, tcp_cfg, con_lifetime);
 			con_lifetime=cfg_get(tcp, tcp_cfg, con_lifetime);
 			tcpconn->timeout=t+con_lifetime;
 			tcpconn->timeout=t+con_lifetime;
 			crt_timeout=con_lifetime;
 			crt_timeout=con_lifetime;
-#ifdef TCP_BUF_WRITE
-			if (unlikely(cfg_get(tcp, tcp_cfg, tcp_buf_write) && 
+#ifdef TCP_ASYNC
+			if (unlikely(cfg_get(tcp, tcp_cfg, async) && 
 							_wbufq_non_empty(tcpconn) )){
 							_wbufq_non_empty(tcpconn) )){
 				if (unlikely(TICKS_GE(t, tcpconn->wbuf_q.wr_timeout))){
 				if (unlikely(TICKS_GE(t, tcpconn->wbuf_q.wr_timeout))){
 					DBG("handle_tcp_child: wr. timeout on CONN_RELEASE for %p "
 					DBG("handle_tcp_child: wr. timeout on CONN_RELEASE for %p "
@@ -2685,7 +2685,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
 											tcpconn->wbuf_q.wr_timeout-t);
 											tcpconn->wbuf_q.wr_timeout-t);
 				}
 				}
 			}
 			}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 			/* re-activate the timer */
 			/* re-activate the timer */
 			tcpconn->timer.f=tcpconn_main_timeout;
 			tcpconn->timer.f=tcpconn_main_timeout;
 			local_timer_reinit(&tcpconn->timer);
 			local_timer_reinit(&tcpconn->timer);
@@ -2693,22 +2693,22 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
 			/* must be after the de-ref*/
 			/* must be after the de-ref*/
 			tcpconn->flags|=(F_CONN_MAIN_TIMER|F_CONN_READ_W|F_CONN_WANTS_RD);
 			tcpconn->flags|=(F_CONN_MAIN_TIMER|F_CONN_READ_W|F_CONN_WANTS_RD);
 			tcpconn->flags&=~(F_CONN_READER|F_CONN_OOB_DATA);
 			tcpconn->flags&=~(F_CONN_READER|F_CONN_OOB_DATA);
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 			if (unlikely(tcpconn->flags & F_CONN_WRITE_W))
 			if (unlikely(tcpconn->flags & F_CONN_WRITE_W))
 				n=io_watch_chg(&io_h, tcpconn->s, POLLIN| POLLOUT, -1);
 				n=io_watch_chg(&io_h, tcpconn->s, POLLIN| POLLOUT, -1);
 			else
 			else
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 				n=io_watch_add(&io_h, tcpconn->s, POLLIN, F_TCPCONN, tcpconn);
 				n=io_watch_add(&io_h, tcpconn->s, POLLIN, F_TCPCONN, tcpconn);
 			if (unlikely(n<0)){
 			if (unlikely(n<0)){
 				LOG(L_CRIT, "ERROR: tcp_main: handle_tcp_child: failed to add"
 				LOG(L_CRIT, "ERROR: tcp_main: handle_tcp_child: failed to add"
 						" new socket to the fd list\n");
 						" new socket to the fd list\n");
 				tcpconn->flags&=~F_CONN_READ_W;
 				tcpconn->flags&=~F_CONN_READ_W;
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 				if (unlikely(tcpconn->flags & F_CONN_WRITE_W)){
 				if (unlikely(tcpconn->flags & F_CONN_WRITE_W)){
 					io_watch_del(&io_h, tcpconn->s, -1, IO_FD_CLOSING);
 					io_watch_del(&io_h, tcpconn->s, -1, IO_FD_CLOSING);
 					tcpconn->flags&=~F_CONN_WRITE_W;
 					tcpconn->flags&=~F_CONN_WRITE_W;
 				}
 				}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 				if (tcpconn_try_unhash(tcpconn));
 				if (tcpconn_try_unhash(tcpconn));
 					tcpconn_put_destroy(tcpconn);
 					tcpconn_put_destroy(tcpconn);
 				break;
 				break;
@@ -2725,12 +2725,12 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
 				 if (tcpconn->s!=-1)
 				 if (tcpconn->s!=-1)
 					io_watch_del(&io_h, tcpconn->s, -1, IO_FD_CLOSING);
 					io_watch_del(&io_h, tcpconn->s, -1, IO_FD_CLOSING);
 				*/
 				*/
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 				if ((tcpconn->flags & F_CONN_WRITE_W) && (tcpconn->s!=-1)){
 				if ((tcpconn->flags & F_CONN_WRITE_W) && (tcpconn->s!=-1)){
 					io_watch_del(&io_h, tcpconn->s, -1, IO_FD_CLOSING);
 					io_watch_del(&io_h, tcpconn->s, -1, IO_FD_CLOSING);
 					tcpconn->flags&=~F_CONN_WRITE_W;
 					tcpconn->flags&=~F_CONN_WRITE_W;
 				}
 				}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 				if (tcpconn_try_unhash(tcpconn))
 				if (tcpconn_try_unhash(tcpconn))
 					tcpconn_put(tcpconn);
 					tcpconn_put(tcpconn);
 				tcpconn_put_destroy(tcpconn); /* deref & delete if refcnt==0 */
 				tcpconn_put_destroy(tcpconn); /* deref & delete if refcnt==0 */
@@ -2772,9 +2772,9 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
 	int flags;
 	int flags;
 	ticks_t t;
 	ticks_t t;
 	ticks_t con_lifetime;
 	ticks_t con_lifetime;
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	ticks_t nxt_timeout;
 	ticks_t nxt_timeout;
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 	
 	
 	ret=-1;
 	ret=-1;
 	if (unlikely(p->unix_sock<=0)){
 	if (unlikely(p->unix_sock<=0)){
@@ -2887,22 +2887,22 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
 			local_timer_add(&tcp_main_ltimer, &tcpconn->timer, 
 			local_timer_add(&tcp_main_ltimer, &tcpconn->timer, 
 								con_lifetime, t);
 								con_lifetime, t);
 			tcpconn->flags|=(F_CONN_MAIN_TIMER|F_CONN_READ_W|F_CONN_WANTS_RD)
 			tcpconn->flags|=(F_CONN_MAIN_TIMER|F_CONN_READ_W|F_CONN_WANTS_RD)
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 					/* not used for now, the connection is sent to tcp_main
 					/* not used for now, the connection is sent to tcp_main
 					 * before knowing whether we can write on it or we should 
 					 * before knowing whether we can write on it or we should 
 					 * wait */
 					 * wait */
 							| (((int)!(tcpconn->flags & F_CONN_WANTS_WR)-1)& 
 							| (((int)!(tcpconn->flags & F_CONN_WANTS_WR)-1)& 
 								F_CONN_WRITE_W)
 								F_CONN_WRITE_W)
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 				;
 				;
 			tcpconn->flags&=~F_CONN_FD_CLOSED;
 			tcpconn->flags&=~F_CONN_FD_CLOSED;
 			flags=POLLIN 
 			flags=POLLIN 
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 					/* not used for now, the connection is sent to tcp_main
 					/* not used for now, the connection is sent to tcp_main
 					 * before knowing if we can write on it or we should 
 					 * before knowing if we can write on it or we should 
 					 * wait */
 					 * wait */
 					| (((int)!(tcpconn->flags & F_CONN_WANTS_WR)-1) & POLLOUT)
 					| (((int)!(tcpconn->flags & F_CONN_WANTS_WR)-1) & POLLOUT)
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 					;
 					;
 			if (unlikely(
 			if (unlikely(
 					io_watch_add(&io_h, tcpconn->s, flags,
 					io_watch_add(&io_h, tcpconn->s, flags,
@@ -2914,7 +2914,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
 				tcpconn_put_destroy(tcpconn);
 				tcpconn_put_destroy(tcpconn);
 			}
 			}
 			break;
 			break;
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 		case CONN_QUEUED_WRITE:
 		case CONN_QUEUED_WRITE:
 			/* received only if the wr. queue is empty and a write finishes
 			/* received only if the wr. queue is empty and a write finishes
 			 * with EAGAIN (common after connect())
 			 * with EAGAIN (common after connect())
@@ -3049,7 +3049,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
 			}
 			}
 			break;
 			break;
 #endif /* TCP_CONNECT_WAIT */
 #endif /* TCP_CONNECT_WAIT */
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 		default:
 		default:
 			LOG(L_CRIT, "BUG: handle_ser_child: unknown cmd %d\n", cmd);
 			LOG(L_CRIT, "BUG: handle_ser_child: unknown cmd %d\n", cmd);
 	}
 	}
@@ -3253,10 +3253,10 @@ static inline int handle_new_connect(struct socket_info* si)
 inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev, 
 inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev, 
 										int fd_i)
 										int fd_i)
 {
 {
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	int empty_q;
 	int empty_q;
 	int bytes;
 	int bytes;
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 	/*  is refcnt!=0 really necessary? 
 	/*  is refcnt!=0 really necessary? 
 	 *  No, in fact it's a bug: I can have the following situation: a send only
 	 *  No, in fact it's a bug: I can have the following situation: a send only
 	 *   tcp connection used by n processes simultaneously => refcnt = n. In 
 	 *   tcp connection used by n processes simultaneously => refcnt = n. In 
@@ -3276,7 +3276,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
 #endif
 #endif
 	/* pass it to child, so remove it from the io watch list  and the local
 	/* pass it to child, so remove it from the io watch list  and the local
 	 *  timer */
 	 *  timer */
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	empty_q=0; /* warning fix */
 	empty_q=0; /* warning fix */
 	if (unlikely((ev & (POLLOUT|POLLERR|POLLHUP)) &&
 	if (unlikely((ev & (POLLOUT|POLLERR|POLLHUP)) &&
 					(tcpconn->flags & F_CONN_WRITE_W))){
 					(tcpconn->flags & F_CONN_WRITE_W))){
@@ -3351,14 +3351,14 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
 		}else
 		}else
 #else
 #else
 	{
 	{
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 			if (unlikely(io_watch_del(&io_h, tcpconn->s, fd_i, 0)==-1)){
 			if (unlikely(io_watch_del(&io_h, tcpconn->s, fd_i, 0)==-1)){
 				LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_del(3)"
 				LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_del(3)"
 							" failed:" " for %p, fd %d\n",
 							" failed:" " for %p, fd %d\n",
 							tcpconn, tcpconn->s);
 							tcpconn, tcpconn->s);
 				goto error;
 				goto error;
 			}
 			}
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 send_to_child:
 send_to_child:
 #endif
 #endif
 		DBG("tcp: DBG: sendig to child, events %x\n", ev);
 		DBG("tcp: DBG: sendig to child, events %x\n", ev);
@@ -3376,7 +3376,7 @@ send_to_child:
 		if (unlikely(send2child(tcpconn)<0)){
 		if (unlikely(send2child(tcpconn)<0)){
 			LOG(L_ERR,"ERROR: handle_tcpconn_ev: no children available\n");
 			LOG(L_ERR,"ERROR: handle_tcpconn_ev: no children available\n");
 			tcpconn->flags&=~F_CONN_READER;
 			tcpconn->flags&=~F_CONN_READER;
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 			if (tcpconn->flags & F_CONN_WRITE_W){
 			if (tcpconn->flags & F_CONN_WRITE_W){
 				if (unlikely(io_watch_del(&io_h, tcpconn->s, fd_i, 0)<0)){
 				if (unlikely(io_watch_del(&io_h, tcpconn->s, fd_i, 0)<0)){
 					LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_del(4)"
 					LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_del(4)"
@@ -3385,7 +3385,7 @@ send_to_child:
 				}
 				}
 				tcpconn->flags&=~F_CONN_WRITE_W;
 				tcpconn->flags&=~F_CONN_WRITE_W;
 			}
 			}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 			tcpconn_put(tcpconn);
 			tcpconn_put(tcpconn);
 			tcpconn_try_unhash(tcpconn); 
 			tcpconn_try_unhash(tcpconn); 
 			tcpconn_put_destroy(tcpconn); /* because of the tcpconn_ref() */
 			tcpconn_put_destroy(tcpconn); /* because of the tcpconn_ref() */
@@ -3458,14 +3458,14 @@ static ticks_t tcpconn_main_timeout(ticks_t t, struct timer_ln* tl, void* data)
 	c=(struct tcp_connection*)data; 
 	c=(struct tcp_connection*)data; 
 	/* or (struct tcp...*)(tl-offset(c->timer)) */
 	/* or (struct tcp...*)(tl-offset(c->timer)) */
 	
 	
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	DBG( "tcp_main: entering timer for %p (ticks=%d, timeout=%d (%d s), "
 	DBG( "tcp_main: entering timer for %p (ticks=%d, timeout=%d (%d s), "
 			"wr_timeout=%d (%d s)), write queue: %d bytes\n",
 			"wr_timeout=%d (%d s)), write queue: %d bytes\n",
 			c, t, c->timeout, TICKS_TO_S(c->timeout-t),
 			c, t, c->timeout, TICKS_TO_S(c->timeout-t),
 			c->wbuf_q.wr_timeout, TICKS_TO_S(c->wbuf_q.wr_timeout-t),
 			c->wbuf_q.wr_timeout, TICKS_TO_S(c->wbuf_q.wr_timeout-t),
 			c->wbuf_q.queued);
 			c->wbuf_q.queued);
 	
 	
-	tcp_async=cfg_get(tcp, tcp_cfg, tcp_buf_write);
+	tcp_async=cfg_get(tcp, tcp_cfg, async);
 	if (likely(TICKS_LT(t, c->timeout) && ( !tcp_async | _wbufq_empty(c) |
 	if (likely(TICKS_LT(t, c->timeout) && ( !tcp_async | _wbufq_empty(c) |
 					TICKS_LT(t, c->wbuf_q.wr_timeout)) )){
 					TICKS_LT(t, c->wbuf_q.wr_timeout)) )){
 		if (unlikely(tcp_async && _wbufq_non_empty(c)))
 		if (unlikely(tcp_async && _wbufq_non_empty(c)))
@@ -3482,12 +3482,12 @@ static ticks_t tcpconn_main_timeout(ticks_t t, struct timer_ln* tl, void* data)
 										BLST_ERR_SEND,
 										BLST_ERR_SEND,
 								c->rcv.proto, &c->rcv.src_su, 0);
 								c->rcv.proto, &c->rcv.src_su, 0);
 #endif /* USE_DST_BLACKLIST */
 #endif /* USE_DST_BLACKLIST */
-#else /* ! TCP_BUF_WRITE */
+#else /* ! TCP_ASYNC */
 	if (TICKS_LT(t, c->timeout)){
 	if (TICKS_LT(t, c->timeout)){
 		/* timeout extended, exit */
 		/* timeout extended, exit */
 		return (ticks_t)(c->timeout - t);
 		return (ticks_t)(c->timeout - t);
 	}
 	}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 	DBG("tcp_main: timeout for %p\n", c);
 	DBG("tcp_main: timeout for %p\n", c);
 	if (likely(c->flags & F_CONN_HASHED)){
 	if (likely(c->flags & F_CONN_HASHED)){
 		c->flags&=~(F_CONN_HASHED|F_CONN_MAIN_TIMER);
 		c->flags&=~(F_CONN_HASHED|F_CONN_MAIN_TIMER);
@@ -3764,12 +3764,12 @@ void destroy_tcp()
 			shm_free(tcp_connections_no);
 			shm_free(tcp_connections_no);
 			tcp_connections_no=0;
 			tcp_connections_no=0;
 		}
 		}
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 		if (tcp_total_wq){
 		if (tcp_total_wq){
 			shm_free(tcp_total_wq);
 			shm_free(tcp_total_wq);
 			tcp_total_wq=0;
 			tcp_total_wq=0;
 		}
 		}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 		if (connection_id){
 		if (connection_id){
 			shm_free(connection_id);
 			shm_free(connection_id);
 			connection_id=0;
 			connection_id=0;
@@ -3826,13 +3826,13 @@ int init_tcp()
 		goto error;
 		goto error;
 	}
 	}
 	*connection_id=1;
 	*connection_id=1;
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	tcp_total_wq=shm_malloc(sizeof(*tcp_total_wq));
 	tcp_total_wq=shm_malloc(sizeof(*tcp_total_wq));
 	if (tcp_total_wq==0){
 	if (tcp_total_wq==0){
 		LOG(L_CRIT, "ERROR: init_tcp: could not alloc globals\n");
 		LOG(L_CRIT, "ERROR: init_tcp: could not alloc globals\n");
 		goto error;
 		goto error;
 	}
 	}
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 	/* alloc hashtables*/
 	/* alloc hashtables*/
 	tcpconn_aliases_hash=(struct tcp_conn_alias**)
 	tcpconn_aliases_hash=(struct tcp_conn_alias**)
 			shm_malloc(TCP_ALIAS_HASH_SIZE* sizeof(struct tcp_conn_alias*));
 			shm_malloc(TCP_ALIAS_HASH_SIZE* sizeof(struct tcp_conn_alias*));
@@ -3981,11 +3981,11 @@ void tcp_get_info(struct tcp_gen_info *ti)
 	ti->tcp_readers=tcp_children_no;
 	ti->tcp_readers=tcp_children_no;
 	ti->tcp_max_connections=tcp_max_connections;
 	ti->tcp_max_connections=tcp_max_connections;
 	ti->tcp_connections_no=*tcp_connections_no;
 	ti->tcp_connections_no=*tcp_connections_no;
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	ti->tcp_write_queued=*tcp_total_wq;
 	ti->tcp_write_queued=*tcp_total_wq;
 #else
 #else
 	ti->tcp_write_queued=0;
 	ti->tcp_write_queued=0;
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 }
 }
 
 
 #endif
 #endif

+ 14 - 16
tcp_options.c

@@ -41,7 +41,7 @@ struct cfg_group_tcp tcp_default_cfg;
 {
 {
 	1, /* fd_cache, default on */
 	1, /* fd_cache, default on */
 	/* tcp async options */
 	/* tcp async options */
-	0, /* tcp_buf_write / tcp_async, default off */
+	0, /* async / tcp_async, default off */
 	1, /* tcp_connect_wait - depends on tcp_async */
 	1, /* tcp_connect_wait - depends on tcp_async */
 	32*1024, /* tcpconn_wq_max - max. write queue len per connection (32k) */
 	32*1024, /* tcpconn_wq_max - max. write queue len per connection (32k) */
 	10*1024*1024, /* tcp_wq_max - max.  overall queued bytes  (10MB)*/
 	10*1024*1024, /* tcp_wq_max - max.  overall queued bytes  (10MB)*/
@@ -147,15 +147,15 @@ void init_tcp_options()
 	tcp_default_cfg.send_timeout_s=DEFAULT_TCP_SEND_TIMEOUT;
 	tcp_default_cfg.send_timeout_s=DEFAULT_TCP_SEND_TIMEOUT;
 	tcp_default_cfg.con_lifetime_s=DEFAULT_TCP_CONNECTION_LIFETIME_S;
 	tcp_default_cfg.con_lifetime_s=DEFAULT_TCP_CONNECTION_LIFETIME_S;
 	tcp_default_cfg.max_connections=tcp_max_connections;
 	tcp_default_cfg.max_connections=tcp_max_connections;
-#ifdef TCP_BUF_WRITE
-	tcp_default_cfg.tcp_buf_write=0;
+#ifdef TCP_ASYNC
+	tcp_default_cfg.async=1;
 	tcp_default_cfg.tcpconn_wq_max=32*1024; /* 32 k */
 	tcp_default_cfg.tcpconn_wq_max=32*1024; /* 32 k */
 	tcp_default_cfg.tcp_wq_max=10*1024*1024; /* 10 MB */
 	tcp_default_cfg.tcp_wq_max=10*1024*1024; /* 10 MB */
 	tcp_default_cfg.tcp_wq_timeout=S_TO_TICKS(tcp_default_cfg.send_timeout_s);
 	tcp_default_cfg.tcp_wq_timeout=S_TO_TICKS(tcp_default_cfg.send_timeout_s);
 #ifdef TCP_CONNECT_WAIT
 #ifdef TCP_CONNECT_WAIT
 	tcp_default_cfg.tcp_connect_wait=1;
 	tcp_default_cfg.tcp_connect_wait=1;
 #endif /* TCP_CONNECT_WAIT */
 #endif /* TCP_CONNECT_WAIT */
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 #ifdef TCP_FD_CACHE
 #ifdef TCP_FD_CACHE
 	tcp_default_cfg.fd_cache=1;
 	tcp_default_cfg.fd_cache=1;
 #endif
 #endif
@@ -229,9 +229,9 @@ static int fix_send_to(void* cfg_h, str* name, void** val)
 	fix_timeout("tcp_send_timeout", &v, DEFAULT_TCP_SEND_TIMEOUT,
 	fix_timeout("tcp_send_timeout", &v, DEFAULT_TCP_SEND_TIMEOUT,
 						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
 						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
 	*val=(void*)(long)v;
 	*val=(void*)(long)v;
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	((struct cfg_group_tcp*)cfg_h)->tcp_wq_timeout=S_TO_TICKS(v);
 	((struct cfg_group_tcp*)cfg_h)->tcp_wq_timeout=S_TO_TICKS(v);
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 	return 0;
 	return 0;
 }
 }
 
 
@@ -244,9 +244,9 @@ static int fix_con_lt(void* cfg_h, str* name, void** val)
 						TICKS_TO_S(MAX_TCP_CON_LIFETIME),
 						TICKS_TO_S(MAX_TCP_CON_LIFETIME),
 						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
 						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
 	*val=(void*)(long)v;
 	*val=(void*)(long)v;
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	((struct cfg_group_tcp*)cfg_h)->con_lifetime=S_TO_TICKS(v);
 	((struct cfg_group_tcp*)cfg_h)->con_lifetime=S_TO_TICKS(v);
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 	return 0;
 	return 0;
 }
 }
 
 
@@ -273,19 +273,17 @@ void tcp_options_check()
 	W_OPT_NC(defer_accept);
 	W_OPT_NC(defer_accept);
 #endif
 #endif
 
 
-#ifndef TCP_BUF_WRITE
-	W_OPT_NC(tcp_buf_write);
+#ifndef TCP_ASYNC
+	W_OPT_NC(async);
 	W_OPT_NC(tcpconn_wq_max);
 	W_OPT_NC(tcpconn_wq_max);
 	W_OPT_NC(tcp_wq_max);
 	W_OPT_NC(tcp_wq_max);
 	W_OPT_NC(tcp_wq_timeout);
 	W_OPT_NC(tcp_wq_timeout);
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 #ifndef TCP_CONNECT_WAIT
 #ifndef TCP_CONNECT_WAIT
 	W_OPT_NC(tcp_connect_wait);
 	W_OPT_NC(tcp_connect_wait);
 #endif /* TCP_CONNECT_WAIT */
 #endif /* TCP_CONNECT_WAIT */
 	
 	
-	if (tcp_default_cfg.tcp_connect_wait && !tcp_default_cfg.tcp_buf_write){
-		WARN("tcp_options: tcp_connect_wait depends on tcp_buf_write, "
-				" disabling...\n");
+	if (tcp_default_cfg.tcp_connect_wait && !tcp_default_cfg.async){
 		tcp_default_cfg.tcp_connect_wait=0;
 		tcp_default_cfg.tcp_connect_wait=0;
 	}
 	}
 	
 	
@@ -328,9 +326,9 @@ void tcp_options_check()
 						TICKS_TO_S(MAX_TCP_CON_LIFETIME),
 						TICKS_TO_S(MAX_TCP_CON_LIFETIME),
 						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
 						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
 	/* compute timeout in ticks */
 	/* compute timeout in ticks */
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	tcp_default_cfg.tcp_wq_timeout=S_TO_TICKS(tcp_default_cfg.send_timeout_s);
 	tcp_default_cfg.tcp_wq_timeout=S_TO_TICKS(tcp_default_cfg.send_timeout_s);
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 	tcp_default_cfg.con_lifetime=S_TO_TICKS(tcp_default_cfg.con_lifetime_s);
 	tcp_default_cfg.con_lifetime=S_TO_TICKS(tcp_default_cfg.con_lifetime_s);
 	tcp_default_cfg.max_connections=tcp_max_connections;
 	tcp_default_cfg.max_connections=tcp_max_connections;
 }
 }

+ 9 - 9
tcp_options.h

@@ -28,17 +28,17 @@
 
 
 #ifdef USE_TCP
 #ifdef USE_TCP
 
 
-#ifndef NO_TCP_BUF_WRITE
-#define TCP_BUF_WRITE /* enabled buffered writing */
-#endif 
+#ifndef NO_TCP_ASYNC
+#define TCP_ASYNC /* enabled async mode */
+#endif
 
 
-#if !defined(NO_TCP_CONNECT_WAIT) && defined(TCP_BUF_WRITE)
+#if !defined(NO_TCP_CONNECT_WAIT) && defined(TCP_ASYNC)
 #define TCP_CONNECT_WAIT /* enable pending connects support */
 #define TCP_CONNECT_WAIT /* enable pending connects support */
 #endif
 #endif
 
 
-#if defined(TCP_CONNECT_WAIT) && !defined(TCP_BUF_WRITE)
-/* check for impossible configuration: TCP_CONNECT_WAIT w/o TCP_BUF_WRITE */
-#warning "disabling TCP_CONNECT_WAIT because TCP_BUF_WRITE is not defined"
+#if defined(TCP_CONNECT_WAIT) && !defined(TCP_ASYNC)
+/* check for impossible configuration: TCP_CONNECT_WAIT w/o TCP_ASYNC */
+#warning "disabling TCP_CONNECT_WAIT because TCP_ASYNC is not defined"
 #undef TCP_CONNECT_WAIT
 #undef TCP_CONNECT_WAIT
 #endif
 #endif
 
 
@@ -117,8 +117,8 @@ struct cfg_group_tcp{
 	int max_connections;
 	int max_connections;
 	int fd_cache; /* on /off */
 	int fd_cache; /* on /off */
 	/* tcp async options */
 	/* tcp async options */
-	int tcp_buf_write; /* on / off */
-	int tcp_connect_wait; /* on / off, depends on tcp_buf_write */
+	int async; /* on / off */
+	int tcp_connect_wait; /* on / off, depends on async */
 	unsigned int tcpconn_wq_max; /* maximum queue len per connection */
 	unsigned int tcpconn_wq_max; /* maximum queue len per connection */
 	unsigned int tcp_wq_max; /* maximum overall queued bytes */
 	unsigned int tcp_wq_max; /* maximum overall queued bytes */