1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

- Made sure that the progress callback is repeatedly called at a regular

interval even during very slow connects.
This commit is contained in:
Daniel Stenberg 2010-01-11 21:38:13 +00:00
parent 78b7d7f7a8
commit 377b2db05b
2 changed files with 34 additions and 16 deletions

View File

@ -7,6 +7,9 @@
Changelog Changelog
Daniel Stenberg (11 Jan 2010) Daniel Stenberg (11 Jan 2010)
- Made sure that the progress callback is repeatedly called at a regular
interval even during very slow connects.
- The tests/runtests.pl script now checks to see if the test case that runs is - The tests/runtests.pl script now checks to see if the test case that runs is
present in the tests/data/Makefile.am and outputs a notice message on the present in the tests/data/Makefile.am and outputs a notice message on the
screen if not. Each test file has to be included in that Makefile.am to get screen if not. Each test file has to be included in that Makefile.am to get

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -89,6 +89,7 @@
#include "inet_ntop.h" #include "inet_ntop.h"
#include "inet_pton.h" #include "inet_pton.h"
#include "sslgen.h" /* for Curl_ssl_check_cxn() */ #include "sslgen.h" /* for Curl_ssl_check_cxn() */
#include "progress.h"
/* The last #include file should be: */ /* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"
@ -192,7 +193,8 @@ long Curl_timeleft(struct connectdata *conn,
#define WAITCONN_FDSET_ERROR 2 #define WAITCONN_FDSET_ERROR 2
static static
int waitconnect(curl_socket_t sockfd, /* socket */ int waitconnect(struct connectdata *conn,
curl_socket_t sockfd, /* socket */
long timeout_msec) long timeout_msec)
{ {
int rc; int rc;
@ -203,21 +205,34 @@ int waitconnect(curl_socket_t sockfd, /* socket */
(void)verifyconnect(sockfd, NULL); (void)verifyconnect(sockfd, NULL);
#endif #endif
/* now select() until we get connect or timeout */ while(1) {
rc = Curl_socket_ready(CURL_SOCKET_BAD, sockfd, (int)timeout_msec);
if(-1 == rc)
/* error, no connect here, try next */
return WAITCONN_SELECT_ERROR;
else if(0 == rc) /* now select() until we get connect or timeout */
/* timeout, no connect today */ rc = Curl_socket_ready(CURL_SOCKET_BAD, sockfd, (int)(timeout_msec>1000?
return WAITCONN_TIMEOUT; 1000:timeout_msec));
if(rc & CURL_CSELECT_ERR) if(Curl_pgrsUpdate(conn))
/* error condition caught */ return CURLE_ABORTED_BY_CALLBACK;
return WAITCONN_FDSET_ERROR;
/* we have a connect! */ if(-1 == rc)
/* error, no connect here, try next */
return WAITCONN_SELECT_ERROR;
else if(0 == rc) {
/* timeout */
timeout_msec -= 1000;
if(timeout_msec <= 0)
return WAITCONN_TIMEOUT;
continue;
}
if(rc & CURL_CSELECT_ERR)
/* error condition caught */
return WAITCONN_FDSET_ERROR;
break;
}
return WAITCONN_CONNECTED; return WAITCONN_CONNECTED;
} }
@ -553,7 +568,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
Curl_expire(data, allow); Curl_expire(data, allow);
/* check for connect without timeout as we want to return immediately */ /* check for connect without timeout as we want to return immediately */
rc = waitconnect(sockfd, 0); rc = waitconnect(conn, sockfd, 0);
if(WAITCONN_CONNECTED == rc) { if(WAITCONN_CONNECTED == rc) {
int error; int error;
@ -823,7 +838,7 @@ singleipconnect(struct connectdata *conn,
case EAGAIN: case EAGAIN:
#endif #endif
#endif #endif
rc = waitconnect(sockfd, timeout_ms); rc = waitconnect(conn, sockfd, timeout_ms);
break; break;
default: default:
/* unknown error, fallthrough and try another address! */ /* unknown error, fallthrough and try another address! */