]> git.tue.mpg.de Git - paraslash.git/commitdiff
net: Clarify code flow of makesock_addrinfo().
authorAndre Noll <maan@systemlinux.org>
Sun, 8 Sep 2013 04:27:26 +0000 (04:27 +0000)
committerAndre Noll <maan@systemlinux.org>
Wed, 1 Jan 2014 17:40:15 +0000 (17:40 +0000)
src != NULL is equivalent to passive, and dst != NULL equivalent
to !passive.

net.c

diff --git a/net.c b/net.c
index 205041fdaec3881c4196d3d7bada084036fea3bf..5e4f13164c26fce85bcbeea55494a0e48244e1ea 100644 (file)
--- 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))