aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-09-30 21:01:23 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-09-30 21:01:23 +0000
commitbe1cece69b2bc7b73c07166ec5e164fabdac1c95 (patch)
tree9191ac933a02caa4ab288e8b64ebd32e0d474f6b
parent45be6d6645ebc20d9fac83ba2b1c17327faced49 (diff)
- Larry Campbell added CURLINFO_OS_ERRNO to curl_easy_getinfo() that allows an
app to retrieve the errno variable after a (connect) failure. It will make sense to provide this for more failures in a more generic way, but let's start like this.
-rw-r--r--CHANGES5
-rw-r--r--TODO-RELEASE4
-rw-r--r--docs/libcurl/curl_easy_getinfo.32
-rw-r--r--include/curl/curl.h3
-rw-r--r--lib/connect.c11
-rw-r--r--lib/getinfo.c19
-rw-r--r--lib/urldata.h2
7 files changed, 31 insertions, 15 deletions
diff --git a/CHANGES b/CHANGES
index ba3ffcced..3ca44ef21 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,11 @@
Changelog
Daniel (30 September 2004)
+- Larry Campbell added CURLINFO_OS_ERRNO to curl_easy_getinfo() that allows an
+ app to retrieve the errno variable after a (connect) failure. It will make
+ sense to provide this for more failures in a more generic way, but let's
+ start like this.
+
- Günter Knauf and Casey O'Donnell worked out an extra #if condition for the
curl/multi.h header to work better in winsock-using apps.
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 0164f2300..af7ec5481 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -3,7 +3,7 @@ Issues not sorted in any particular order.
To get fixed in 7.12.2 (planned release: mid October 2004)
======================
-40 - Larry Campbell's curl_easy_getinfo patch
+40 - fixed
41 - Fedor Karpelevitch's formpost path basename patch
@@ -15,7 +15,7 @@ To get fixed in 7.12.2 (planned release: mid October 2004)
45 - Chris' suspected race condition in the windows threaded resolver
-46 - Casey O'Donnell's multi.h winsock header fix
+46 - fixed
47 - Peter Sylvester's patch related to the new SRP on the TLS layer
diff --git a/docs/libcurl/curl_easy_getinfo.3 b/docs/libcurl/curl_easy_getinfo.3
index dcf993f04..fba414a7f 100644
--- a/docs/libcurl/curl_easy_getinfo.3
+++ b/docs/libcurl/curl_easy_getinfo.3
@@ -110,6 +110,8 @@ CURLOPT_HTTPAUTH option for \fIcurl_easy_setopt(3)\fP. (Added in 7.10.8)
.IP CURLINFO_PROXYAUTH_AVAIL
Pass a pointer to a long to receive a bitmask indicating the authentication
method(s) available for your proxy authentication. (Added in 7.10.8)
+.IP CURLINFO_OS_ERRNO
+Pass a pointer to a long to receive the errno variable from a connect failure.
.SH RETURN VALUE
If the operation was successful, CURLE_OK is returned. Otherwise an
appropriate error code will be returned.
diff --git a/include/curl/curl.h b/include/curl/curl.h
index 767a833c8..f6df95394 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -1178,9 +1178,10 @@ typedef enum {
CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG + 22,
CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23,
CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24,
+ CURLINFO_OS_ERRNO = CURLINFO_LONG + 25,
/* Fill in new entries below here! */
- CURLINFO_LASTONE = 23
+ CURLINFO_LASTONE = 26
} CURLINFO;
/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
diff --git a/lib/connect.c b/lib/connect.c
index f6d10f60e..5e8c047bc 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -355,7 +355,8 @@ static CURLcode bindlocal(struct connectdata *conn,
}
if(!bindworked) {
- failf(data, "%s", Curl_strerror(conn, Curl_ourerrno()));
+ data->state.os_errno = Curl_ourerrno();
+ failf(data, "%s", Curl_strerror(conn, data->state.os_errno));
return CURLE_HTTP_PORT_FAILED;
}
@@ -508,12 +509,14 @@ CURLcode Curl_is_connected(struct connectdata *conn,
rc = waitconnect(sockfd, 0);
if(WAITCONN_CONNECTED == rc) {
- if (verifyconnect(sockfd, NULL)) {
+ int error;
+ if (verifyconnect(sockfd, &error)) {
/* we are connected, awesome! */
*connected = TRUE;
return CURLE_OK;
}
/* nope, not connected for real */
+ data->state.os_errno = error;
infof(data, "Connection failed\n");
if(trynextip(conn, sockindex, connected)) {
code = CURLE_COULDNT_CONNECT;
@@ -635,8 +638,10 @@ singleipconnect(struct connectdata *conn,
}
else if(WAITCONN_TIMEOUT == rc)
infof(data, "Timeout\n");
- else
+ else {
+ data->state.os_errno = error;
infof(data, "%s\n", Curl_strerror(conn, error));
+ }
/* connect failed or timed out */
sclose(sockfd);
diff --git a/lib/getinfo.c b/lib/getinfo.c
index bdb909e3c..88627d6e4 100644
--- a/lib/getinfo.c
+++ b/lib/getinfo.c
@@ -1,8 +1,8 @@
/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
@@ -10,7 +10,7 @@
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
- *
+ *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
@@ -56,7 +56,7 @@ CURLcode Curl_initinfo(struct SessionHandle *data)
info->httpcode = 0;
info->httpversion=0;
info->filetime=-1; /* -1 is an illegal time and thus means unknown */
-
+
if (info->contenttype)
free(info->contenttype);
info->contenttype = NULL;
@@ -78,7 +78,7 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
default:
return CURLE_BAD_FUNCTION_ARGUMENT;
case CURLINFO_STRING:
- param_charp = va_arg(arg, char **);
+ param_charp = va_arg(arg, char **);
if(NULL == param_charp)
return CURLE_BAD_FUNCTION_ARGUMENT;
break;
@@ -93,7 +93,7 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
return CURLE_BAD_FUNCTION_ARGUMENT;
break;
}
-
+
switch(info) {
case CURLINFO_EFFECTIVE_URL:
*param_charp = data->change.url?data->change.url:(char *)"";
@@ -167,6 +167,9 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
case CURLINFO_PROXYAUTH_AVAIL:
*param_longp = data->info.proxyauthavail;
break;
+ case CURLINFO_OS_ERRNO:
+ *param_longp = data->state.os_errno;
+ break;
default:
return CURLE_BAD_FUNCTION_ARGUMENT;
}
diff --git a/lib/urldata.h b/lib/urldata.h
index f1de21904..ae2642ee7 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -733,7 +733,7 @@ struct UrlState {
bool errorbuf; /* Set to TRUE if the error buffer is already filled in.
This must be set to FALSE every time _easy_perform() is
called. */
-
+ int os_errno; /* filled in with errno whenever an error occurs */
#ifdef HAVE_SIGNAL
/* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */
void (*prev_signal)(int sig);