mirror of
https://github.com/curl/curl.git
synced 2026-08-26 01:53:31 +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
|
|
@ -4949,7 +4949,7 @@ static CURLcode cr_exp100_read(struct Curl_easy *data,
|
|||
DEBUGF(infof(data, "cr_exp100_read, start AWAITING_CONTINUE, "
|
||||
"timeout %dms", data->set.expect_100_timeout));
|
||||
ctx->state = EXP100_AWAITING_CONTINUE;
|
||||
ctx->start = curlx_now();
|
||||
ctx->start = data->progress.now;
|
||||
Curl_expire(data, data->set.expect_100_timeout, EXPIRE_100_TIMEOUT);
|
||||
*nread = 0;
|
||||
*eos = FALSE;
|
||||
|
|
@ -4960,7 +4960,7 @@ static CURLcode cr_exp100_read(struct Curl_easy *data,
|
|||
*eos = FALSE;
|
||||
return CURLE_READ_ERROR;
|
||||
case EXP100_AWAITING_CONTINUE:
|
||||
ms = curlx_timediff_ms(curlx_now(), ctx->start);
|
||||
ms = curlx_timediff_ms(data->progress.now, ctx->start);
|
||||
if(ms < data->set.expect_100_timeout) {
|
||||
DEBUGF(infof(data, "cr_exp100_read, AWAITING_CONTINUE, not expired"));
|
||||
*nread = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue