mirror of
https://github.com/curl/curl.git
synced 2026-08-26 01:53:31 +03:00
multi: alter transfer timeout ordering
- Check whether a connection has succeded before checking whether it's timed out. This means if we've connected quickly, but subsequently been descheduled, we allow the connection to succeed. Note, if we timeout, but between checking the timeout, and connecting to the server the connection succeeds, we will allow it to go ahead. This is viewed as an acceptable trade off. - Add additional failf logging around failed connection attempts to propogate the cause up to the caller. Co-Authored-by: Martin Howarth Closes #7178
This commit is contained in:
parent
a5ab72d5ed
commit
0842175fa4
3 changed files with 100 additions and 54 deletions
|
|
@ -872,15 +872,6 @@ CURLcode Curl_is_connected(struct Curl_easy *data,
|
|||
|
||||
now = Curl_now();
|
||||
|
||||
/* figure out how long time we have left to connect */
|
||||
allow = Curl_timeleft(data, &now, TRUE);
|
||||
|
||||
if(allow < 0) {
|
||||
/* time-out, bail out, go home */
|
||||
failf(data, "Connection time-out");
|
||||
return CURLE_OPERATION_TIMEDOUT;
|
||||
}
|
||||
|
||||
if(SOCKS_STATE(conn->cnnct.state)) {
|
||||
/* still doing SOCKS */
|
||||
result = connect_SOCKS(data, sockindex, connected);
|
||||
|
|
@ -994,6 +985,7 @@ CURLcode Curl_is_connected(struct Curl_easy *data,
|
|||
Curl_strerror(error, buffer, sizeof(buffer)));
|
||||
#endif
|
||||
|
||||
allow = Curl_timeleft(data, &now, TRUE);
|
||||
conn->timeoutms_per_addr[i] = conn->tempaddr[i]->ai_next == NULL ?
|
||||
allow : allow / 2;
|
||||
ainext(conn, i, TRUE);
|
||||
|
|
@ -1006,6 +998,21 @@ CURLcode Curl_is_connected(struct Curl_easy *data,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now that we've checked whether we are connected, check whether we've
|
||||
* already timed out.
|
||||
*
|
||||
* First figure out how long time we have left to connect */
|
||||
|
||||
allow = Curl_timeleft(data, &now, TRUE);
|
||||
|
||||
if(allow < 0) {
|
||||
/* time-out, bail out, go home */
|
||||
failf(data, "Connection timeout after %ld ms",
|
||||
Curl_timediff(now, data->progress.t_startsingle));
|
||||
return CURLE_OPERATION_TIMEDOUT;
|
||||
}
|
||||
|
||||
if(result &&
|
||||
(conn->tempsock[0] == CURL_SOCKET_BAD) &&
|
||||
(conn->tempsock[1] == CURL_SOCKET_BAD)) {
|
||||
|
|
@ -1031,9 +1038,10 @@ CURLcode Curl_is_connected(struct Curl_easy *data,
|
|||
else
|
||||
hostname = conn->host.name;
|
||||
|
||||
failf(data, "Failed to connect to %s port %ld: %s",
|
||||
hostname, conn->port,
|
||||
Curl_strerror(error, buffer, sizeof(buffer)));
|
||||
failf(data, "Failed to connect to %s port %ld after %ld ms: %s",
|
||||
hostname, conn->port,
|
||||
Curl_timediff(now, data->progress.t_startsingle),
|
||||
Curl_strerror(error, buffer, sizeof(buffer)));
|
||||
|
||||
Curl_quic_disconnect(data, conn, 0);
|
||||
Curl_quic_disconnect(data, conn, 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue