diff options
author | Björn Stenberg <bjorn@haxx.se> | 2013-11-12 21:09:03 +0100 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2013-11-14 19:56:59 +0000 |
commit | ed1662c374361adf8a3bd44be8490891f37e074a (patch) | |
tree | 7b1883e40bedb3fee8b49005915e31c5e3be56a3 | |
parent | 1f0616ea1a89606c6fec7a0855dda12ef5c7a9be (diff) |
connect: Return the socket descriptor even on fail
singleipconnect() did not return the open socket descriptor on some
errors, thereby sometimes causing a socket leak. This patch ensures
the socket is always returned.
-rw-r--r-- | lib/connect.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/connect.c b/lib/connect.c index 67f73343c..91aac8b88 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -1027,6 +1027,8 @@ singleipconnect(struct connectdata *conn, conn->bits.ipv6 = (addr.family == AF_INET6)?TRUE:FALSE; #endif + *sockp = sockfd;
+
if(-1 == rc) { switch (error) { case EINPROGRESS: @@ -1040,7 +1042,6 @@ singleipconnect(struct connectdata *conn, case EAGAIN: #endif #endif - *sockp = sockfd; return CURLE_OK; default: @@ -1053,8 +1054,6 @@ singleipconnect(struct connectdata *conn, return CURLE_COULDNT_CONNECT; } } - else - *sockp = sockfd; return CURLE_OK; } |