diff options
Diffstat (limited to 'lib/sockunion.c')
| -rw-r--r-- | lib/sockunion.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/lib/sockunion.c b/lib/sockunion.c index 559ae37ffb..ab8d8be3e5 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -175,15 +175,11 @@ static int sockunion_sizeof(const union sockunion *su) return ret; } -/* sockunion_connect returns - -1 : error occured - 0 : connect success - 1 : connect is in progress */ +/* Performs a non-blocking connect(). */ enum connect_result sockunion_connect(int fd, const union sockunion *peersu, unsigned short port, ifindex_t ifindex) { int ret; - int val; union sockunion su; memcpy(&su, peersu, sizeof(union sockunion)); @@ -203,18 +199,12 @@ enum connect_result sockunion_connect(int fd, const union sockunion *peersu, break; } - /* Make socket non-block. */ - val = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, val | O_NONBLOCK); - /* Call connect function. */ ret = connect(fd, (struct sockaddr *)&su, sockunion_sizeof(&su)); /* Immediate success */ - if (ret == 0) { - fcntl(fd, F_SETFL, val); + if (ret == 0) return connect_success; - } /* If connect is in progress then return 1 else it's real error. */ if (ret < 0) { @@ -227,8 +217,6 @@ enum connect_result sockunion_connect(int fd, const union sockunion *peersu, } } - fcntl(fd, F_SETFL, val); - return connect_in_progress; } |
