From: Andre Noll Date: Sun, 8 Sep 2013 04:27:26 +0000 (+0000) Subject: net: Clarify code flow of makesock_addrinfo(). X-Git-Tag: v0.5.2~11^2~9 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=166c7ec3e1b77ee8d4d8e50dd8314ca4c683ae26;p=paraslash.git net: Clarify code flow of makesock_addrinfo(). src != NULL is equivalent to passive, and dst != NULL equivalent to !passive. --- diff --git a/net.c b/net.c index 205041fd..5e4f1316 100644 --- a/net.c +++ b/net.c @@ -455,17 +455,17 @@ static int makesock_addrinfo(unsigned l4type, bool passive, struct addrinfo *ai, } flowopt_setopts(sockfd, fo); - if (src) { + if (passive) { if (bind(sockfd, src->ai_addr, src->ai_addrlen) < 0) { close(sockfd); goto get_next_src; } /* bind completed successfully */ break; + } else { + if (connect(sockfd, dst->ai_addr, dst->ai_addrlen) == 0) + break; /* connection completed successfully */ } - - if (dst && connect(sockfd, dst->ai_addr, dst->ai_addrlen) == 0) - break; /* connection completed successfully */ close(sockfd); get_next_dst: if (dst && (dst = dst->ai_next))