mirror of
https://github.com/curl/curl.git
synced 2026-08-26 08:23:36 +03:00
timeout handling: auto-detect effective timeout
When checking a transfer for being expired via `Curl_timeleft_ms()`, eleminate the `bool connecting` parameter and have the function check the `mstate` of the transfer instead. Advantages: * eleminate the caller needing awareness if the transfer is connecting or in a later state * fix pingpong timeout handling to check the correct timeout during "proto_connect" phases * avoid using "connecting" timeouts during establishing a secondary connection (e.g. FTP) since this would use the timestamp from the original, primary connect and thus be wrong Reported-by: Wyuer on github Fixes #20347 Closes #20354
This commit is contained in:
parent
3d354f55b7
commit
8ce16e7bf2
25 changed files with 73 additions and 79 deletions
10
lib/multi.c
10
lib/multi.c
|
|
@ -351,6 +351,11 @@ static void multi_warn_debug(struct Curl_multi *multi, struct Curl_easy *data)
|
|||
#define multi_warn_debug(x, y) Curl_nop_stmt
|
||||
#endif
|
||||
|
||||
bool Curl_is_connecting(struct Curl_easy *data)
|
||||
{
|
||||
return data->mstate < MSTATE_DO;
|
||||
}
|
||||
|
||||
static CURLMcode multi_xfers_add(struct Curl_multi *multi,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
|
|
@ -1720,14 +1725,13 @@ static bool multi_handle_timeout(struct Curl_easy *data,
|
|||
bool *stream_error,
|
||||
CURLcode *result)
|
||||
{
|
||||
bool connect_timeout = data->mstate < MSTATE_DO;
|
||||
timediff_t timeout_ms;
|
||||
|
||||
timeout_ms = Curl_timeleft_ms(data, connect_timeout);
|
||||
timeout_ms = Curl_timeleft_ms(data);
|
||||
if(timeout_ms < 0) {
|
||||
/* Handle timed out */
|
||||
struct curltime since;
|
||||
if(connect_timeout)
|
||||
if(Curl_is_connecting(data))
|
||||
since = data->progress.t_startsingle;
|
||||
else
|
||||
since = data->progress.t_startop;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue