mirror of
https://github.com/curl/curl.git
synced 2026-08-25 14:23:39 +03:00
lib: keep timestamp in easy handle
Use `data->progress.now` as the timestamp of proecssing a transfer. Update it on significant events and refrain from calling `curlx_now()` in many places. The problem this addresses is a) calling curlx_now() has costs, depending on platform. Calling it every time results in 25% increase `./runtest` duration on macOS. b) we used to pass a `struct curltime *` around to save on calls, but when some method directly use `curx_now()` and some use the passed pointer, the transfer experienes non-linear time. This results in timeline checks to report events in the wrong order. By keeping a timestamp in the easy handle and updating it there, no longer invoking `curlx_now()` in the "lower" methods, the transfer can observer a steady clock progression. Add documentation in docs/internals/TIME-KEEPING.md Reported-by: Viktor Szakats Fixes #19935 Closes #19961
This commit is contained in:
parent
425a2aa1af
commit
2de22a00c7
67 changed files with 598 additions and 458 deletions
|
|
@ -3178,7 +3178,7 @@ static CURLcode ftp_connect(struct Curl_easy *data,
|
|||
conn->bits.ftp_use_control_ssl = TRUE;
|
||||
}
|
||||
|
||||
Curl_pp_init(pp); /* once per transfer */
|
||||
Curl_pp_init(pp, &data->progress.now); /* once per transfer */
|
||||
|
||||
/* When we connect, we start in the state where we await the 220
|
||||
response */
|
||||
|
|
@ -3314,7 +3314,7 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status,
|
|||
* data has been transferred. This happens when doing through NATs etc that
|
||||
* abandon old silent connections.
|
||||
*/
|
||||
pp->response = curlx_now(); /* timeout relative now */
|
||||
pp->response = data->progress.now; /* timeout relative now */
|
||||
result = getftpresponse(data, &nread, &ftpcode);
|
||||
|
||||
if(!nread && (CURLE_OPERATION_TIMEDOUT == result)) {
|
||||
|
|
@ -3434,7 +3434,7 @@ static CURLcode ftp_sendquote(struct Curl_easy *data,
|
|||
|
||||
result = Curl_pp_sendf(data, &ftpc->pp, "%s", cmd);
|
||||
if(!result) {
|
||||
pp->response = curlx_now(); /* timeout relative now */
|
||||
pp->response = data->progress.now; /* timeout relative now */
|
||||
result = getftpresponse(data, &nread, &ftpcode);
|
||||
}
|
||||
if(result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue