aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-10-15 23:44:28 +0200
committerDaniel Stenberg <daniel@haxx.se>2011-10-15 23:44:28 +0200
commit1a416cd27a37dac23a36063ced06ecc99fcd41e2 (patch)
tree2186953768b9544e8020e85fc1b5fb78cdf24e34
parent54ef47a5a0de388d0ace96cd1c354127888a374d (diff)
singleipconnect: don't clobber errno
Save the errno value immediately after a connect() failure so that it won't get reset to something else before we read it. Bug: http://curl.haxx.se/mail/lib-2011-10/0066.html Reported by: Frank Van Uffelen and Fabian Hiernaux
-rw-r--r--lib/connect.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 7f0171f46..309ba355a 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -836,7 +836,7 @@ singleipconnect(struct connectdata *conn,
{
struct Curl_sockaddr_ex addr;
int rc;
- int error;
+ int error = 0;
bool isconnected = FALSE;
struct SessionHandle *data = conn->data;
curl_socket_t sockfd;
@@ -946,6 +946,8 @@ singleipconnect(struct connectdata *conn,
/* Connect TCP sockets, bind UDP */
if(!isconnected && (conn->socktype == SOCK_STREAM)) {
rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
+ if(-1 == rc)
+ error = SOCKERRNO;
conn->connecttime = Curl_tvnow();
if(conn->num_addr > 1)
Curl_expire(data, conn->timeoutms_per_addr);
@@ -954,8 +956,6 @@ singleipconnect(struct connectdata *conn,
rc = 0;
if(-1 == rc) {
- error = SOCKERRNO;
-
switch (error) {
case EINPROGRESS:
case EWOULDBLOCK: