mirror of
https://github.com/curl/curl.git
synced 2026-08-26 12:53:35 +03:00
time-keeping: keep timestamp in multi, always update
Always use curlx_now() when calling Curl_pgrs_now(data). Tests with the "manual" updates to now proved differ more then 100ms in parallel testing. Add `curlx_nowp()` to set current time into a struct curltime. Add `curlx_ptimediff_ms() and friends, passing pointers. Update documentation. Closes #19998
This commit is contained in:
parent
308c347c8b
commit
b4be1f271e
61 changed files with 471 additions and 502 deletions
10
lib/easy.c
10
lib/easy.c
|
|
@ -607,11 +607,11 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
|
|||
CURLMsg *msg;
|
||||
struct pollfd fds[4];
|
||||
int pollrc;
|
||||
struct curltime before;
|
||||
struct curltime start;
|
||||
const unsigned int numfds = populate_fds(fds, ev);
|
||||
|
||||
/* get the time stamp to use to figure out how long poll takes */
|
||||
before = curlx_now();
|
||||
curlx_pnow(&start);
|
||||
|
||||
result = poll_fds(ev, fds, numfds, &pollrc);
|
||||
if(result)
|
||||
|
|
@ -647,7 +647,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
|
|||
/* If nothing updated the timeout, we decrease it by the spent time.
|
||||
* If it was updated, it has the new timeout time stored already.
|
||||
*/
|
||||
timediff_t spent_ms = curlx_timediff_ms(curlx_now(), before);
|
||||
timediff_t spent_ms = curlx_timediff_ms(curlx_now(), start);
|
||||
if(spent_ms > 0) {
|
||||
#if DEBUG_EV_POLL
|
||||
curl_mfprintf(stderr, "poll timeout %ldms not updated, decrease by "
|
||||
|
|
@ -995,7 +995,6 @@ CURL *curl_easy_duphandle(CURL *d)
|
|||
if(dupset(outcurl, data))
|
||||
goto fail;
|
||||
|
||||
Curl_pgrs_now_set(outcurl); /* start of API call */
|
||||
outcurl->progress.hide = data->progress.hide;
|
||||
outcurl->progress.callback = data->progress.callback;
|
||||
|
||||
|
|
@ -1155,7 +1154,6 @@ CURLcode curl_easy_pause(CURL *d, int action)
|
|||
if(Curl_is_in_callback(data))
|
||||
recursive = TRUE;
|
||||
|
||||
Curl_pgrs_now_set(data); /* start of API call */
|
||||
recv_paused = Curl_xfer_recv_is_paused(data);
|
||||
recv_paused_new = (action & CURLPAUSE_RECV);
|
||||
send_paused = Curl_xfer_send_is_paused(data);
|
||||
|
|
@ -1180,7 +1178,7 @@ CURLcode curl_easy_pause(CURL *d, int action)
|
|||
Curl_multi_mark_dirty(data); /* make it run */
|
||||
/* On changes, tell application to update its timers. */
|
||||
if(changed) {
|
||||
if(Curl_update_timer(data->multi, &data->progress.now) && !result)
|
||||
if(Curl_update_timer(data->multi) && !result)
|
||||
result = CURLE_ABORTED_BY_CALLBACK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue