Browse code

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 <libor@iptel.org>

Andrei Pelinescu-Onciul authored on 19/03/2009 17:59:14
Showing 1 changed files
... ...
@@ -1025,10 +1025,10 @@ inline static int tcp_do_connect(	union sockaddr_union* server,
1025 1025
 	if (likely(cfg_get(tcp, tcp_cfg, async))){
1026 1026
 again:
1027 1027
 		n=connect(s, &server->s, sockaddru_len(*server));
1028
-		if (unlikely(n==-1)){
1029
-			if (errno==EINTR) goto again;
1028
+		if (likely(n==-1)){ /*non-blocking => most probable EINPROGRESS*/
1030 1029
 			if (likely(errno==EINPROGRESS))
1031 1030
 				*state=S_CONN_CONNECT;
1031
+			else if (errno==EINTR) goto again;
1032 1032
 			else if (errno!=EALREADY){
1033 1033
 #ifdef USE_DST_BLACKLIST
1034 1034
 				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)
2723 2723
 					tcpconn->flags&=~F_CONN_WRITE_W;
2724 2724
 				}
2725 2725
 #endif /* TCP_ASYNC */
2726
-				if (tcpconn_try_unhash(tcpconn));
2726
+				if (tcpconn_try_unhash(tcpconn))
2727 2727
 					tcpconn_put_destroy(tcpconn);
2728 2728
 				break;
2729 2729
 			}