1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

corrected the #include files

This commit is contained in:
Daniel Stenberg 2001-10-01 11:25:27 +00:00
parent c5fdeef41d
commit ede5b54edc

View File

@ -24,14 +24,24 @@
#include "setup.h" #include "setup.h"
#ifndef WIN32 #ifndef WIN32
/* headers for non-win32 */
#include <sys/time.h> #include <sys/time.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h> #include <netdb.h>
#include <sys/fcntl.h> #endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
@ -65,7 +75,7 @@
*/ */
static static
int nonblock(int socket, /* operate on this */ int nonblock(int socket, /* operate on this */
int nonblock /* TRUE or FALSE */) int nonblock /* TRUE or FALSE */)
{ {
#undef SETBLOCK #undef SETBLOCK
#ifdef HAVE_O_NONBLOCK #ifdef HAVE_O_NONBLOCK
@ -149,12 +159,16 @@ int waitconnect(int sockfd, /* socket */
*/ */
CURLcode Curl_connecthost(struct connectdata *conn, CURLcode Curl_connecthost(struct connectdata *conn,
long timeout_ms,
int sockfd, /* input socket, or -1 if none */ int sockfd, /* input socket, or -1 if none */
int *socket) int *socket)
{ {
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
int rc; int rc;
struct timeval after;
struct timeval before = Curl_tvnow();
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
/* /*
* Connecting with IPv6 support is so much easier and cleanly done * Connecting with IPv6 support is so much easier and cleanly done
@ -178,11 +192,16 @@ CURLcode Curl_connecthost(struct connectdata *conn,
break; break;
/* asynchronous connect, wait for connect or timeout */ /* asynchronous connect, wait for connect or timeout */
rc = waitconnect(sockfd, timeout); rc = waitconnect(sockfd, timeout_ms);
if(0 != rc) { if(0 != rc) {
/* connect failed or timed out */ /* connect failed or timed out */
sclose(sockfd); sclose(sockfd);
sockfd = -1; sockfd = -1;
/* get a new timeout for next attempt */
after = Curl_tvnow();
timeout_ms -= (long)(Curl_tvdiff(after, before)*1000);
before = after;
continue; continue;
} }
@ -200,7 +219,6 @@ CURLcode Curl_connecthost(struct connectdata *conn,
* Connecting with IPv4-only support * Connecting with IPv4-only support
*/ */
int aliasindex; int aliasindex;
int timeout_ms = 10000; /* while testing */
/* non-block socket */ /* non-block socket */
nonblock(sockfd, TRUE); nonblock(sockfd, TRUE);
@ -250,8 +268,13 @@ CURLcode Curl_connecthost(struct connectdata *conn,
} }
} }
if(0 != rc) if(0 != rc) {
/* get a new timeout for next attempt */
after = Curl_tvnow();
timeout_ms -= (long)(Curl_tvdiff(after, before)*1000);
before = after;
continue; /* try next address */ continue; /* try next address */
}
else else
break; break;
} }