use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling
This commit is contained in:
@@ -115,19 +115,6 @@ singleipconnect(struct connectdata *conn,
|
||||
long timeout_ms,
|
||||
bool *connected);
|
||||
|
||||
/*
|
||||
* Curl_sockerrno() returns the *socket-related* errno (or equivalent) on this
|
||||
* platform to hide platform specific for the function that calls this.
|
||||
*/
|
||||
int Curl_sockerrno(void)
|
||||
{
|
||||
#ifdef USE_WINSOCK
|
||||
return (int)WSAGetLastError();
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Curl_nonblock() set the given socket to either blocking or non-blocking
|
||||
* mode based on the 'nonblock' boolean argument. This function is highly
|
||||
@@ -332,7 +319,7 @@ static CURLcode bindlocal(struct connectdata *conn,
|
||||
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
|
||||
data->set.device, strlen(data->set.device)+1) != 0) {
|
||||
/* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n",
|
||||
sockfd, data->set.device, Curl_strerror(Curl_sockerrno())); */
|
||||
sockfd, data->set.device, Curl_strerror(SOCKERRNO)); */
|
||||
infof(data, "SO_BINDTODEVICE %s failed\n",
|
||||
data->set.device);
|
||||
/* This is typically "errno 1, error: Operation not permitted" if
|
||||
@@ -409,7 +396,7 @@ static CURLcode bindlocal(struct connectdata *conn,
|
||||
break;
|
||||
} while(1);
|
||||
|
||||
data->state.os_errno = Curl_sockerrno();
|
||||
data->state.os_errno = SOCKERRNO;
|
||||
failf(data, "bind failure: %s",
|
||||
Curl_strerror(conn, data->state.os_errno));
|
||||
return CURLE_HTTP_PORT_FAILED;
|
||||
@@ -453,7 +440,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
|
||||
|
||||
if( -1 == getsockopt(sockfd, SOL_SOCKET, SO_ERROR,
|
||||
(void *)&err, &errSize))
|
||||
err = Curl_sockerrno();
|
||||
err = SOCKERRNO;
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
/* Always returns this error, bug in CE? */
|
||||
@@ -472,7 +459,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
|
||||
#else
|
||||
(void)sockfd;
|
||||
if (error)
|
||||
*error = Curl_sockerrno();
|
||||
*error = SOCKERRNO;
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
@@ -613,7 +600,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
||||
infof(data, "Connection failed\n");
|
||||
|
||||
if(trynextip(conn, sockindex, connected)) {
|
||||
error = Curl_sockerrno();
|
||||
error = SOCKERRNO;
|
||||
data->state.os_errno = error;
|
||||
failf(data, "Failed connect to %s:%d; %s",
|
||||
conn->host.name, conn->port, Curl_strerror(conn,error));
|
||||
@@ -645,7 +632,7 @@ static void tcpnodelay(struct connectdata *conn,
|
||||
if(setsockopt(sockfd, proto, TCP_NODELAY, (void *)&onoff,
|
||||
sizeof(onoff)) < 0)
|
||||
infof(data, "Could not set TCP_NODELAY: %s\n",
|
||||
Curl_strerror(conn, Curl_sockerrno()));
|
||||
Curl_strerror(conn, SOCKERRNO));
|
||||
else
|
||||
infof(data,"TCP_NODELAY set\n");
|
||||
#else
|
||||
@@ -667,7 +654,7 @@ static void nosigpipe(struct connectdata *conn,
|
||||
if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff,
|
||||
sizeof(onoff)) < 0)
|
||||
infof(data, "Could not set SO_NOSIGPIPE: %s\n",
|
||||
Curl_strerror(conn, Curl_sockerrno()));
|
||||
Curl_strerror(conn, SOCKERRNO));
|
||||
}
|
||||
#else
|
||||
#define nosigpipe(x,y)
|
||||
@@ -731,7 +718,7 @@ singleipconnect(struct connectdata *conn,
|
||||
rc = 0;
|
||||
|
||||
if(-1 == rc) {
|
||||
error = Curl_sockerrno();
|
||||
error = SOCKERRNO;
|
||||
|
||||
switch (error) {
|
||||
case EINPROGRESS:
|
||||
|
||||
Reference in New Issue
Block a user