mirror of
https://github.com/curl/curl.git
synced 2026-07-26 02:07:16 +03:00
- 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.
This commit is contained in:
parent
45be6d6645
commit
be1cece69b
7 changed files with 31 additions and 15 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue