浏览代码

tcp: typo & minor optimization

- fixed ';' after if() on tcp connection free (luckily that code path was
 not very common and it was even more improbable to have a ref'ed connection
 at that point).

- changed unlikely() into likely() when checking connect() return in async
mode (it's much more probable to get an EINPROGRESS).

Reported-by:  Libor Chocholaty  <[email protected]>
Andrei Pelinescu-Onciul 16 年之前
父节点
当前提交
575a0b47b9
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      tcp_main.c

+ 3 - 3
tcp_main.c

@@ -1025,10 +1025,10 @@ inline static int tcp_do_connect(	union sockaddr_union* server,
 	if (likely(cfg_get(tcp, tcp_cfg, async))){
 again:
 		n=connect(s, &server->s, sockaddru_len(*server));
-		if (unlikely(n==-1)){
-			if (errno==EINTR) goto again;
+		if (likely(n==-1)){ /*non-blocking => most probable EINPROGRESS*/
 			if (likely(errno==EINPROGRESS))
 				*state=S_CONN_CONNECT;
+			else if (errno==EINTR) goto again;
 			else if (errno!=EALREADY){
 #ifdef USE_DST_BLACKLIST
 				if (cfg_get(core, core_cfg, use_dst_blacklist))
@@ -2723,7 +2723,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
 					tcpconn->flags&=~F_CONN_WRITE_W;
 				}
 #endif /* TCP_ASYNC */
-				if (tcpconn_try_unhash(tcpconn));
+				if (tcpconn_try_unhash(tcpconn))
 					tcpconn_put_destroy(tcpconn);
 				break;
 			}