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.
This commit is contained in:

committed by
Steve Holme

parent
1f0616ea1a
commit
ed1662c374
@@ -1027,6 +1027,8 @@ singleipconnect(struct connectdata *conn,
|
|||||||
conn->bits.ipv6 = (addr.family == AF_INET6)?TRUE:FALSE;
|
conn->bits.ipv6 = (addr.family == AF_INET6)?TRUE:FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
*sockp = sockfd;
|
||||||
|
|
||||||
if(-1 == rc) {
|
if(-1 == rc) {
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case EINPROGRESS:
|
case EINPROGRESS:
|
||||||
@@ -1040,7 +1042,6 @@ singleipconnect(struct connectdata *conn,
|
|||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
*sockp = sockfd;
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1053,8 +1054,6 @@ singleipconnect(struct connectdata *conn,
|
|||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
*sockp = sockfd;
|
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user