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:
Stefan Eissing 2026-01-19 11:38:35 +01:00 committed by Daniel Stenberg
parent 3d354f55b7
commit 8ce16e7bf2
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
25 changed files with 73 additions and 79 deletions

View file

@ -148,7 +148,8 @@ static CURLcode test_unit1303(const char *arg)
NOW(run[i].now_s, run[i].now_us);
TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
easy->progress.now = now;
timeout = Curl_timeleft_now_ms(easy, &now, run[i].connecting);
easy->mstate = run[i].connecting ? MSTATE_INIT : MSTATE_DO;
timeout = Curl_timeleft_now_ms(easy, &now);
if(timeout != run[i].result)
fail(run[i].comment);
}