Artifactspublic-v0

curl

master
ply4 git calls434 ms294 KiB2 cachedprotocol v2
771 lines24 KiBRaw
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "curl_setup.h"
26#include "urldata.h"
27#include "curl_trc.h"
28#include "multiif.h"
29#include "progress.h"
30#include "transfer.h"
31#include "curlx/strcopy.h"
33#ifndef CURL_DISABLE_PROGRESS_METER
34/* Provide a string that is 7 letters long (plus the zero byte).
36 @unittest 1636 */
37UNITTEST void time2str(char *r, size_t rsize, curl_off_t seconds);
38UNITTEST void time2str(char *r, size_t rsize, curl_off_t seconds)
40 curl_off_t h;
41 if(seconds <= 0) {
42 curlx_strcopy(r, rsize, STRCONST(" "));
43 return;
44 }
45 h = seconds / 3600;
46 if(h <= 99) {
47 curl_off_t m = (seconds - (h * 3600)) / 60;
48 if(h <= 9) {
49 curl_off_t s = (seconds - (h * 3600)) - (m * 60);
50 if(h)
51 curl_msnprintf(r, rsize, "%" FMT_OFF_T ":%02" FMT_OFF_T ":"
52 "%02" FMT_OFF_T, h, m, s);
53 else
54 curl_msnprintf(r, rsize, " %02" FMT_OFF_T ":%02" FMT_OFF_T, m, s);
55 }
56 else
57 curl_msnprintf(r, rsize, "%" FMT_OFF_T "h %02" FMT_OFF_T "m", h, m);
58 }
59 else {
60 curl_off_t d = seconds / 86400;
61 h = (seconds - (d * 86400)) / 3600;
62 if(d <= 99)
63 curl_msnprintf(r, rsize, "%2" FMT_OFF_T "d %02" FMT_OFF_T "h", d, h);
64 else if(d <= 999)
65 curl_msnprintf(r, rsize, "%6" FMT_OFF_T "d", d);
66 else { /* more than 999 days */
67 curl_off_t m = d / 30;
68 if(m <= 999)
69 curl_msnprintf(r, rsize, "%6" FMT_OFF_T "m", m);
70 else { /* more than 999 months */
71 curl_off_t y = d / 365;
72 if(y <= 99999)
73 curl_msnprintf(r, rsize, "%6" FMT_OFF_T "y", y);
74 else
75 curlx_strcopy(r, rsize, STRCONST(">99999y"));
76 }
77 }
78 }
81/* The point of this function would be to return a string of the input data,
82 but never longer than 6 columns (+ one zero byte).
83 Add suffix k, M, G when suitable...
85 @unittest 1636 */
86UNITTEST char *max6out(curl_off_t bytes, char *max6, size_t mlen);
87UNITTEST char *max6out(curl_off_t bytes, char *max6, size_t mlen)
89 /* a signed 64-bit value is 8192 petabytes maximum, shown as
90 8.0E (exabytes)*/
91 if(bytes < 100000)
92 curl_msnprintf(max6, mlen, "%6" CURL_FORMAT_CURL_OFF_T, bytes);
93 else {
94 static const char unit[] = { 'k', 'M', 'G', 'T', 'P', 'E', 0 };
95 int k = 0;
96 curl_off_t nbytes;
97 curl_off_t rest;
98 do {
99 nbytes = bytes / 1024;
100 if(nbytes < 1000)
101 break;
102 bytes = nbytes;
103 k++;
104 DEBUGASSERT(unit[k]);
105 } while(unit[k]);
106 rest = bytes % 1024;
107 if(nbytes <= 99)
108 /* xx.yyU */
109 curl_msnprintf(max6, mlen, "%2" CURL_FORMAT_CURL_OFF_T
110 ".%02" CURL_FORMAT_CURL_OFF_T "%c", nbytes,
111 rest * 100 / 1024, unit[k]);
112 else
113 /* xxx.yU */
114 curl_msnprintf(max6, mlen, "%3" CURL_FORMAT_CURL_OFF_T
115 ".%" CURL_FORMAT_CURL_OFF_T "%c", nbytes,
116 rest * 10 / 1024, unit[k]);
117 }
118 return max6;
120#endif
122static void pgrs_speedinit(struct Curl_easy *data)
124 memset(&data->state.keeps_speed, 0, sizeof(struct curltime));
127/*
128 * @unittest 1606
129 */
130UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data,
131 const struct curltime *pnow);
132UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data,
133 const struct curltime *pnow)
135 if(!data->set.low_speed_time || !data->set.low_speed_limit ||
136 Curl_xfer_recv_is_paused(data) || Curl_xfer_send_is_paused(data))
137 /* A paused transfer is not qualified for speed checks */
138 return CURLE_OK;
140 if(data->progress.current_speed >= 0) {
141 if(data->progress.current_speed < data->set.low_speed_limit) {
142 if(!data->state.keeps_speed.tv_sec)
143 /* under the limit at this moment */
144 data->state.keeps_speed = *pnow;
145 else {
146 /* how long has it been under the limit */
147 timediff_t howlong =
148 curlx_ptimediff_ms(pnow, &data->state.keeps_speed);
150 if(howlong >= data->set.low_speed_time * 1000) {
151 /* too long */
152 failf(data, "Operation too slow. Less than %" FMT_OFF_T
153 " bytes/sec transferred the last %u seconds",
154 data->set.low_speed_limit, data->set.low_speed_time);
155 return CURLE_OPERATION_TIMEDOUT;
156 }
157 }
158 }
159 else
160 /* faster right now */
161 data->state.keeps_speed.tv_sec = 0;
162 }
164 /* since low speed limit is enabled, set the expire timer to make this
165 connection's speed get checked again in a second */
166 Curl_expire_set(data, EXPIRE_SPEEDCHECK, 1000, pnow);
168 return CURLE_OK;
171const struct curltime *Curl_pgrs_now(struct Curl_easy *data)
173 curlx_pnow(&data->progress.now);
174 return &data->progress.now;
177/* New proposed interface, 9th of February 2000:
179 pgrsStartNow() - sets start time
180 pgrsSetDownloadSize(x) - known expected download size
181 pgrsSetUploadSize(x) - known expected upload size
182 pgrsSetDownloadCounter() - amount of data currently downloaded
183 pgrsSetUploadCounter() - amount of data currently uploaded
184 pgrsUpdate() - show progress
185 pgrsDone() - transfer complete
186 */
188int Curl_pgrsDone(struct Curl_easy *data, const struct curltime *pnow)
190 int rc;
191 data->progress.delta.lastshow_us = -1;
192 rc = Curl_pgrsUpdateX(data, pnow); /* the final (forced) update */
193 if(rc)
194 return rc;
196 if(!data->progress.hide && !data->progress.callback)
197 /* only output if we do not use a progress callback and we are not
198 * hidden */
199 curl_mfprintf(data->set.err, "\n");
201 return 0;
204void Curl_pgrsReset(struct Curl_easy *data)
206 Curl_pgrsSetUploadCounter(data, 0);
207 data->progress.dl.cur_size = 0;
208 Curl_pgrsSetUploadSize(data, -1);
209 Curl_pgrsSetDownloadSize(data, -1);
210 data->progress.speeder_c = 0; /* reset speed records */
211 data->progress.deliver = 0;
212 pgrs_speedinit(data);
215/* reset the known transfer sizes */
216void Curl_pgrsResetTransferSizes(struct Curl_easy *data)
218 Curl_pgrsSetDownloadSize(data, -1);
219 Curl_pgrsSetUploadSize(data, -1);
222void Curl_pgrsRecvPause(struct Curl_easy *data, bool enable)
224 if(!enable) {
225 data->progress.speeder_c = 0; /* reset speed records */
226 pgrs_speedinit(data); /* reset low speed measurements */
227 }
230void Curl_pgrsSendPause(struct Curl_easy *data, bool enable)
232 if(!enable) {
233 data->progress.speeder_c = 0; /* reset speed records */
234 pgrs_speedinit(data); /* reset low speed measurements */
235 }
238#ifdef CURLVERBOSE
239static const char * const pgrs_timer_names[] = {
240 "PGRS-NONE",
241 "PGRS-STARTOP",
242 "PGRS-STARTSINGLE",
243 "PGRS-POSTQUEUE",
244 "PGRS-NAMELOOKUP",
245 "PGRS-CONNECT",
246 "PGRS-APPCONNECT",
247 "PGRS-PRETRANSFER",
248 "PGRS-STARTTRANSFER",
249 "PGRS-POSTRANSFER",
250 "PGRS-REDIRECT",
251};
253static const char *pgrs_timer_name(timerid timer)
255 if((size_t)timer < CURL_ARRAYSIZE(pgrs_timer_names))
256 return pgrs_timer_names[(size_t)timer];
257 return "?";
259#endif /* CURLVERBOSE */
261/*
262 * Curl_pgrsTimeWas(). Store the timestamp time at the given label.
263 */
264void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer,
265 struct curltime timestamp)
267 timediff_t *delta = NULL;
269 switch(timer) {
270 default:
271 case TIMER_NONE:
272 /* mistake filter */
273 break;
274 case TIMER_STARTOP:
275 /* This is set at the start of a transfer */
276 data->progress.delta.startop_us =
277 curlx_ptimediff_us(&timestamp, &data->progress.start);
278 data->progress.delta.startqueue_us = data->progress.delta.startop_us;
279 break;
280 case TIMER_STARTSINGLE:
281 /* This is set at the start of each single transfer */
282 data->progress.delta.startsingle_us =
283 curlx_ptimediff_us(&timestamp, &data->progress.start);
284 data->progress.startransfer_added = FALSE;
285 break;
286 case TIMER_POSTQUEUE:
287 /* Queue time is accumulative from all involved redirects */
288 data->progress.total.queued_us +=
289 curlx_ptimediff_us(&timestamp, &data->progress.start) -
290 data->progress.delta.startqueue_us;
291 break;
292 case TIMER_NAMELOOKUP:
293 delta = &data->progress.total.nslookup_us;
294 break;
295 case TIMER_CONNECT:
296 delta = &data->progress.total.connect_us;
297 break;
298 case TIMER_APPCONNECT:
299 delta = &data->progress.total.appconnect_us;
300 break;
301 case TIMER_PRETRANSFER:
302 delta = &data->progress.total.pretransfer_us;
303 break;
304 case TIMER_STARTTRANSFER:
305 /* prevent updating t_starttransfer unless:
306 * 1. this is the first time we are setting t_starttransfer
307 * 2. a redirect has occurred since the last time t_starttransfer was set
308 * This prevents repeated invocations of the function from incorrectly
309 * changing the t_starttransfer time.
310 */
311 if(data->progress.startransfer_added) {
312 CURL_TRC_M(data, "[%s] ignored", pgrs_timer_name(timer));
313 return;
314 }
315 data->progress.startransfer_added = TRUE;
316 delta = &data->progress.total.starttransfer_us;
317 break;
318 case TIMER_POSTRANSFER:
319 delta = &data->progress.total.posttransfer_us;
320 break;
321 case TIMER_REDIRECT:
322 data->progress.delta.startredirect_us =
323 curlx_ptimediff_us(&timestamp, &data->progress.start);
324 /* transfer starts queueing again */
325 data->progress.delta.startqueue_us =
326 data->progress.delta.startredirect_us;
327 break;
328 }
329 if(delta) {
330 timediff_t us = curlx_ptimediff_us(&timestamp, &data->progress.start) -
331 data->progress.delta.startsingle_us;
332 if(us < 1)
333 us = 1; /* make sure at least one microsecond passed */
334 *delta += us;
335 CURL_TRC_M(data, "[%s] added %" FMT_TIMEDIFF_T "us",
336 pgrs_timer_name(timer), us);
337 }
338 else
339 CURL_TRC_M(data, "[%s] set", pgrs_timer_name(timer));
342/*
343 * Curl_pgrsTime(). Store the current time at the given label. This fetches a
344 * fresh "now" and returns it.
345 *
346 * @unittest: 1399
347 */
348void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
350 Curl_pgrsTimeWas(data, timer, *Curl_pgrs_now(data));
353void Curl_pgrsStart(struct Curl_easy *data, const struct curltime *pnow)
355 struct Progress *p = &data->progress;
357 if(!pnow)
358 pnow = Curl_pgrs_now(data);
359 p->speeder_c = 0; /* reset the progress meter display */
360 p->start = *pnow;
361 memset(&p->delta, 0, sizeof(p->delta));
362 memset(&p->total, 0, sizeof(p->total));
363 p->startransfer_added = FALSE;
364 p->dl.cur_size = 0;
365 p->ul.cur_size = 0;
366 /* the sizes are unknown at start */
367 p->dl_size_known = FALSE;
368 p->ul_size_known = FALSE;
371/* check that the 'delta' amount of bytes are okay to deliver to the
372 application, or return error if not. */
373CURLcode Curl_pgrs_deliver_check(struct Curl_easy *data, size_t delta)
375 if(data->set.max_filesize &&
376 ((curl_off_t)delta > data->set.max_filesize - data->progress.deliver)) {
377 failf(data, "Would have exceeded max file size");
378 return CURLE_FILESIZE_EXCEEDED;
379 }
380 return CURLE_OK;
383/* this counts how much data is delivered to the application, which
384 in compressed cases may differ from downloaded amount */
385void Curl_pgrs_deliver_inc(struct Curl_easy *data, size_t delta)
387 data->progress.deliver += delta;
390void Curl_pgrs_download_inc(struct Curl_easy *data, size_t delta)
392 if(delta) {
393 data->progress.dl.cur_size += delta;
394 Curl_rlimit_drain(&data->progress.dl.rlimit, delta, NULL);
395 }
398void Curl_pgrs_upload_inc(struct Curl_easy *data, size_t delta)
400 if(delta) {
401 data->progress.ul.cur_size += delta;
402 Curl_rlimit_drain(&data->progress.ul.rlimit, delta, NULL);
403 }
406/*
407 * Set the number of uploaded bytes so far.
408 */
409void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size)
411 data->progress.ul.cur_size = size;
414void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size)
416 if(size >= 0) {
417 data->progress.dl.total_size = size;
418 data->progress.dl_size_known = TRUE;
419 }
420 else {
421 data->progress.dl.total_size = 0;
422 data->progress.dl_size_known = FALSE;
423 }
426void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
428 if(size >= 0) {
429 data->progress.ul.total_size = size;
430 data->progress.ul_size_known = TRUE;
431 }
432 else {
433 data->progress.ul.total_size = 0;
434 data->progress.ul_size_known = FALSE;
435 }
438void Curl_pgrsEarlyData(struct Curl_easy *data, curl_off_t sent)
440 data->progress.earlydata_sent = sent;
443/* returns the average speed in bytes / second */
444static curl_off_t trspeed(curl_off_t size, /* number of bytes */
445 curl_off_t us) /* microseconds */
447 if(us < 1)
448 return size * 1000000;
449 else if(size < CURL_OFF_T_MAX / 1000000)
450 return (size * 1000000) / us;
451 else if(us >= 1000000)
452 return size / (us / 1000000);
453 else
454 return CURL_OFF_T_MAX;
457/* returns TRUE if it is time to show the progress meter */
458static bool progress_calc(struct Curl_easy *data,
459 const struct curltime *pnow)
461 struct Progress * const p = &data->progress;
462 int i_next, i_oldest, i_latest;
463 timediff_t duration_us, elapsed_us;
464 curl_off_t amount;
466 /* The time spent so far (from the start) in microseconds */
467 elapsed_us = curlx_ptimediff_us(pnow, &p->start);
468 p->total.spent_us = elapsed_us;
469 p->dl.speed = trspeed(p->dl.cur_size, p->total.spent_us);
470 p->ul.speed = trspeed(p->ul.cur_size, p->total.spent_us);
472 if(!p->speeder_c) { /* no previous record exists */
473 p->speed_amount[0] = p->dl.cur_size + p->ul.cur_size;
474 p->speed_time[0] = elapsed_us;
475 p->speeder_c++;
476 /* use the overall average at the start */
477 p->current_speed = p->ul.speed + p->dl.speed;
478 p->delta.lastshow_us = elapsed_us;
479 return TRUE;
480 }
481 /* We have at least one record now. Where to put the next and
482 * where is the latest one? */
483 i_next = p->speeder_c % CURL_SPEED_RECORDS;
484 i_latest = (i_next > 0) ? (i_next - 1) : (CURL_SPEED_RECORDS - 1);
486 /* Make a new record only when some time has passed.
487 * Too frequent calls otherwise ruin the history. */
488 if((elapsed_us - p->speed_time[i_latest]) >= (1000 * 1000)) {
489 p->speeder_c++;
490 i_latest = i_next;
491 p->speed_amount[i_latest] = p->dl.cur_size + p->ul.cur_size;
492 p->speed_time[i_latest] = elapsed_us;
493 }
494 else if(data->req.done) {
495 /* When a transfer is done, and we did not have a current speed
496 * already, update the last record. Otherwise, stay at the speed
497 * we have. The last chunk of data, when rate limiting, would increase
498 * reported speed since it no longer measures a full second. */
499 if(!p->current_speed) {
500 p->speed_amount[i_latest] = p->dl.cur_size + p->ul.cur_size;
501 p->speed_time[i_latest] = elapsed_us;
502 }
503 }
504 else {
505 /* transfer ongoing, wait for more time to pass. */
506 return FALSE;
507 }
509 i_oldest = (p->speeder_c < CURL_SPEED_RECORDS) ? 0 :
510 ((i_latest + 1) % CURL_SPEED_RECORDS);
512 /* How much we transferred between oldest and current records */
513 amount = p->speed_amount[i_latest] - p->speed_amount[i_oldest];
514 /* How long this took */
515 duration_us = p->speed_time[i_latest] - p->speed_time[i_oldest];
516 if(duration_us <= 0)
517 duration_us = 1;
519 if(amount > (CURL_OFF_T_MAX / 1000000)) {
520 /* the 'amount' value is bigger than would fit in 64 bits if
521 multiplied with 1000000, so we use the double math for this */
522 p->current_speed =
523 (curl_off_t)(((double)amount * 1000000.0) / (double)duration_us);
524 }
525 else {
526 p->current_speed = amount * 1000000 / duration_us;
527 }
529 if((p->delta.lastshow_us >= 0) && !data->req.done &&
530 ((elapsed_us - p->delta.lastshow_us) < (1000 * 1000)))
531 return FALSE;
532 p->delta.lastshow_us = elapsed_us;
533 return TRUE;
536#ifndef CURL_DISABLE_PROGRESS_METER
538struct pgrs_estimate {
539 curl_off_t secs;
540 curl_off_t percent;
541};
543static curl_off_t pgrs_est_percent(curl_off_t total, curl_off_t cur)
545 if(total > 10000)
546 return cur / (total / 100);
547 else if(total > 0)
548 return (cur * 100) / total;
549 return 0;
552static void pgrs_estimates(struct pgrs_dir *d,
553 bool total_known,
554 struct pgrs_estimate *est)
556 est->secs = 0;
557 est->percent = 0;
558 if(total_known && (d->speed > 0)) {
559 est->secs = d->total_size / d->speed;
560 est->percent = pgrs_est_percent(d->total_size, d->cur_size);
561 }
564static void progress_meter(struct Curl_easy *data)
566 struct Progress *p = &data->progress;
567 char max6[6][7];
568 struct pgrs_estimate dl_estm;
569 struct pgrs_estimate ul_estm;
570 struct pgrs_estimate total_estm;
571 curl_off_t total_cur_size;
572 curl_off_t total_expected_size;
573 curl_off_t dl_size;
574 char time_left[8];
575 char time_total[8];
576 char time_spent[8];
577 curl_off_t cur_secs = (curl_off_t)p->total.spent_us / 1000000;
579 if(!p->headers_out) {
580 if(data->state.resume_from) {
581 curl_mfprintf(data->set.err,
582 "** Resuming transfer from byte position %" FMT_OFF_T "\n",
583 data->state.resume_from);
584 }
585 curl_mfprintf(data->set.err,
586 " %% Total %% Received %% Xferd Average Speed "
587 "Time Time Time Current\n"
588 " Dload Upload "
589 "Total Spent Left Speed\n");
590 p->headers_out = TRUE; /* headers are shown */
591 }
593 /* Figure out the estimated time of arrival for upload and download */
594 pgrs_estimates(&p->ul, (bool)p->ul_size_known, &ul_estm);
595 pgrs_estimates(&p->dl, (bool)p->dl_size_known, &dl_estm);
597 /* Since both happen at the same time, total expected duration is max. */
598 total_estm.secs = CURLMAX(ul_estm.secs, dl_estm.secs);
599 /* create the three time strings */
600 time2str(time_left, sizeof(time_left),
601 total_estm.secs > 0 ? (total_estm.secs - cur_secs) : 0);
602 time2str(time_total, sizeof(time_total), total_estm.secs);
603 time2str(time_spent, sizeof(time_spent), cur_secs);
605 /* Get the total amount of data expected to get transferred */
606 total_expected_size = p->ul_size_known ? p->ul.total_size : p->ul.cur_size;
608 dl_size = p->dl_size_known ? p->dl.total_size : p->dl.cur_size;
610 /* integer overflow check */
611 if((CURL_OFF_T_MAX - total_expected_size) < dl_size)
612 total_expected_size = CURL_OFF_T_MAX; /* capped */
613 else
614 total_expected_size += dl_size;
616 /* We have transferred this much so far */
617 total_cur_size = p->dl.cur_size + p->ul.cur_size;
619 /* Get the percentage of data transferred so far */
620 total_estm.percent = pgrs_est_percent(total_expected_size, total_cur_size);
622 curl_mfprintf(data->set.err,
623 "\r"
624 "%3" FMT_OFF_T " %s "
625 "%3" FMT_OFF_T " %s "
626 "%3" FMT_OFF_T " %s %s %s %s %s %s %s",
627 total_estm.percent, /* 3 letters */ /* total % */
628 max6out(total_expected_size, max6[2],
629 sizeof(max6[2])), /* total size */
630 dl_estm.percent, /* 3 letters */ /* rcvd % */
631 max6out(p->dl.cur_size, max6[0],
632 sizeof(max6[0])), /* rcvd size */
633 ul_estm.percent, /* 3 letters */ /* xfer % */
634 max6out(p->ul.cur_size, max6[1],
635 sizeof(max6[1])), /* xfer size */
636 max6out(p->dl.speed, max6[3],
637 sizeof(max6[3])), /* avrg dl speed */
638 max6out(p->ul.speed, max6[4],
639 sizeof(max6[4])), /* avrg ul speed */
640 time_total, /* 7 letters */ /* total time */
641 time_spent, /* 7 letters */ /* time spent */
642 time_left, /* 7 letters */ /* time left */
643 max6out(p->current_speed, max6[5],
644 sizeof(max6[5])) /* current speed */
645 );
647 /* we flush the output stream to make it appear as soon as possible */
648 fflush(data->set.err);
650#else /* CURL_DISABLE_PROGRESS_METER */
651#define progress_meter(x) Curl_nop_stmt
652#endif
654/*
655 * Curl_pgrsUpdate() returns 0 for success or the value returned by the
656 * progress callback!
657 */
658static CURLcode pgrsupdate(struct Curl_easy *data, bool showprogress)
660 if(!data->progress.hide) {
661 int rc;
662 if(data->set.fxferinfo) {
663 /* There is a callback set, call that */
664 struct Curl_mapi_guard guard;
665 CURL_CBAPI_START(&guard, data, easy_fxferinfo);
666 rc = data->set.fxferinfo(data->set.progress_client,
667 data->progress.dl.total_size,
668 data->progress.dl.cur_size,
669 data->progress.ul.total_size,
670 data->progress.ul.cur_size);
671 CURL_CBAPI_END(&guard);
672 if(rc != CURL_PROGRESSFUNC_CONTINUE) {
673 if(rc) {
674 failf(data, "Callback aborted");
675 return CURLE_ABORTED_BY_CALLBACK;
676 }
677 return CURLE_OK;
678 }
679 }
680 else if(data->set.fprogress) {
681 /* The older deprecated callback is set, call that */
682 struct Curl_mapi_guard guard;
683 CURL_CBAPI_START(&guard, data, easy_fprogress);
684 rc = data->set.fprogress(data->set.progress_client,
685 (double)data->progress.dl.total_size,
686 (double)data->progress.dl.cur_size,
687 (double)data->progress.ul.total_size,
688 (double)data->progress.ul.cur_size);
689 CURL_CBAPI_END(&guard);
690 if(rc != CURL_PROGRESSFUNC_CONTINUE) {
691 if(rc) {
692 failf(data, "Callback aborted");
693 return CURLE_ABORTED_BY_CALLBACK;
694 }
695 return CURLE_OK;
696 }
697 }
699 if(showprogress)
700 progress_meter(data);
701 }
703 return CURLE_OK;
706static CURLcode pgrs_update(struct Curl_easy *data,
707 const struct curltime *pnow)
709 bool showprogress = progress_calc(data, pnow);
710 return pgrsupdate(data, showprogress);
713CURLcode Curl_pgrsUpdate(struct Curl_easy *data)
715 return pgrs_update(data, Curl_pgrs_now(data));
718CURLcode Curl_pgrsUpdateX(struct Curl_easy *data,
719 const struct curltime *pnow)
721 return pgrs_update(data, pnow);
724CURLcode Curl_pgrsCheckX(struct Curl_easy *data,
725 const struct curltime *pnow)
727 CURLcode result;
729 result = pgrs_update(data, pnow);
730 if(!result && !data->req.done)
731 result = pgrs_speedcheck(data, pnow);
732 return result;
735CURLcode Curl_pgrsCheck(struct Curl_easy *data)
737 return Curl_pgrsCheckX(data, Curl_pgrs_now(data));
740/*
741 * Update all progress, do not do progress meter/callbacks.
742 */
743void Curl_pgrsUpdate_nometer(struct Curl_easy *data)
745 (void)progress_calc(data, Curl_pgrs_now(data));
748void Curl_pgrsCompleted(struct Curl_easy *data)
750 struct Progress * const p = &data->progress;
751 p->total.spent_us = curlx_ptimediff_us(Curl_pgrs_now(data), &p->start);
754timediff_t Curl_pgrs_since_ms(struct Curl_easy *data,
755 const struct curltime *pnow,
756 timerid timer)
758 if(!pnow)
759 pnow = Curl_pgrs_now(data);
760 switch(timer) {
761 case TIMER_STARTOP:
762 return (curlx_ptimediff_us(pnow, &data->progress.start) -
763 data->progress.delta.startop_us) / 1000;
764 case TIMER_STARTSINGLE:
765 return (curlx_ptimediff_us(pnow, &data->progress.start) -
766 data->progress.delta.startsingle_us) / 1000;
767 default:
768 DEBUGASSERT(0);
769 return 0;
770 }
Diagnostics4 git calls · 434 ms
CallStatusSizeTime0434 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=427
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=4
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2007.1 KiB427 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=7314
git.response.cache=MISS
git.response.duration_ms=427
git.fetch.wants=c6432d68f73399a771c8a00d2dff8de54effe8bc
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=7314
git.pkt.payload.max=7293
git.sideband.band1.bytes=7292
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e19b15eb90b86e
Request
9859ccbc…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format