FTP: perform active connections non-blocking

1- Two new error codes are introduced.

CURLE_FTP_ACCEPT_FAILED to be set whenever ACCEPTing fails because of
FTP server connected.

CURLE_FTP_ACCEPT_TIMEOUT to be set whenever ACCEPTing timeouts.

Neither of these errors are considered fatal and control connection
remains OK because it could just be a firewall blocking server to
connect to the client.

2- One new setopt option was introduced.

CURLOPT_ACCEPTTIMEOUT_MS

It sets the maximum amount of time FTP client is going to wait for a
server to connect. Internal default accept timeout is 60 seconds.
This commit is contained in:
Gokhan Sengun
2011-12-19 14:35:20 +01:00
committed by Daniel Stenberg
parent 5527417afa
commit c834213ad5
20 changed files with 366 additions and 132 deletions

View File

@@ -98,6 +98,34 @@ singleipconnect(struct connectdata *conn,
curl_socket_t *sock,
bool *connected);
/*
* Curl_timeleft_accept() returns the amount of milliseconds left allowed for
* waiting server to connect. If the value is negative, the timeout time has
* already elapsed.
*
* The start time is stored in progress.t_acceptdata - as set with
* Curl_pgrsTime(..., TIMER_STARTACCEPT);
*
*/
long Curl_timeleft_accept(struct SessionHandle *data)
{
long timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
struct timeval now;
if(data->set.accepttimeout > 0)
timeout_ms = data->set.accepttimeout;
now = Curl_tvnow();
/* subtract elapsed time */
timeout_ms -= Curl_tvdiff(now, data->progress.t_acceptdata);
if(!timeout_ms)
/* avoid returning 0 as that means no timeout! */
return -1;
return timeout_ms;
}
/*
* Curl_timeleft() returns the amount of milliseconds left allowed for the
* transfer/connection. If the value is negative, the timeout time has already