singleipconnect() could return the file descriptor of an open socket
even though the function returned a CURLE_COULDNT_CONNECT error code
from commit
ed1662c374361a and
02fbc26d59c591.
This could cause tests 19, 704 and 1233 to fail on FreeBSD, AIX and
Solaris.
while(ai && ai->ai_family != family)
ai = ai->ai_next;
+
if(ai) {
rc = singleipconnect(conn, ai, &conn->tempsock[tempindex]);
conn->tempaddr[tempindex] = ai;
conn->bits.ipv6 = (addr.family == AF_INET6)?TRUE:FALSE;
#endif
- *sockp = sockfd;
-
if(-1 == rc) {
- switch (error) {
+ switch(error) {
case EINPROGRESS:
case EWOULDBLOCK:
#if defined(EAGAIN)
case EAGAIN:
#endif
#endif
- return CURLE_OK;
+ res = CURLE_OK;
+ break;
default:
/* unknown error, fallthrough and try another address! */
data->state.os_errno = error;
/* connect failed */
- return CURLE_COULDNT_CONNECT;
+ Curl_closesocket(conn, sockfd);
+ res = CURLE_COULDNT_CONNECT;
}
}
- return CURLE_OK;
+ if(!res)
+ *sockp = sockfd;
+
+ return res;
}
/*