mirror of https://github.com/moparisthebest/curl
SM made the connection timeout work for windows boxes!
This commit is contained in:
parent
870cea2aea
commit
022099266e
24
lib/url.c
24
lib/url.c
|
@ -1060,6 +1060,11 @@ ConnectionStore(struct UrlData *data,
|
||||||
static CURLcode ConnectPlease(struct UrlData *data,
|
static CURLcode ConnectPlease(struct UrlData *data,
|
||||||
struct connectdata *conn)
|
struct connectdata *conn)
|
||||||
{
|
{
|
||||||
|
#if defined(WIN32)
|
||||||
|
unsigned long nonblock = 0;
|
||||||
|
fd_set connectfd;
|
||||||
|
struct timeval conntimeout;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ENABLE_IPV6
|
#ifndef ENABLE_IPV6
|
||||||
conn->firstsocket = socket(AF_INET, SOCK_STREAM, 0);
|
conn->firstsocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
@ -1222,10 +1227,29 @@ static CURLcode ConnectPlease(struct UrlData *data,
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
/* non-zero nonblock value sets socket as nonblocking under Win32 */
|
||||||
|
#if defined(WIN32)
|
||||||
|
FD_ZERO (&connectfd);
|
||||||
|
FD_SET(conn->firstsocket, &connectfd);
|
||||||
|
if (conn->data->connecttimeout > 0) {
|
||||||
|
nonblock = 1;
|
||||||
|
}
|
||||||
|
ioctlsocket(conn->firstsocket, FIONBIO, &nonblock);
|
||||||
|
#endif
|
||||||
if (connect(conn->firstsocket,
|
if (connect(conn->firstsocket,
|
||||||
(struct sockaddr *) &(conn->serv_addr),
|
(struct sockaddr *) &(conn->serv_addr),
|
||||||
sizeof(conn->serv_addr)
|
sizeof(conn->serv_addr)
|
||||||
) < 0) {
|
) < 0) {
|
||||||
|
#if defined(WIN32)
|
||||||
|
conntimeout.tv_sec = conn->data->connecttimeout;
|
||||||
|
conntimeout.tv_usec = 0;
|
||||||
|
if(-1 != select (conn->firstsocket + 1, NULL, &connectfd, NULL, &conntimeout)) {
|
||||||
|
if (FD_ISSET(conn->firstsocket, &connectfd))
|
||||||
|
return CURLE_OK;
|
||||||
|
else
|
||||||
|
errno = EINTR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
switch(errno) {
|
switch(errno) {
|
||||||
#ifdef ECONNREFUSED
|
#ifdef ECONNREFUSED
|
||||||
/* this should be made nicer */
|
/* this should be made nicer */
|
||||||
|
|
Loading…
Reference in New Issue