progress.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) Daniel Stenberg, <[email protected]>, 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"
  25. #include "urldata.h"
  26. #include "sendf.h"
  27. #include "multiif.h"
  28. #include "progress.h"
  29. #include "curlx/timeval.h"
  30. /* check rate limits within this many recent milliseconds, at minimum. */
  31. #define MIN_RATE_LIMIT_PERIOD 3000
  32. #ifndef CURL_DISABLE_PROGRESS_METER
  33. /* Provide a string that is 2 + 1 + 2 + 1 + 2 = 8 letters long (plus the zero
  34. byte) */
  35. static void time2str(char *r, curl_off_t seconds)
  36. {
  37. curl_off_t h;
  38. if(seconds <= 0) {
  39. strcpy(r, "--:--:--");
  40. return;
  41. }
  42. h = seconds / 3600;
  43. if(h <= 99) {
  44. curl_off_t m = (seconds - (h * 3600)) / 60;
  45. curl_off_t s = (seconds - (h * 3600)) - (m * 60);
  46. curl_msnprintf(r, 9, "%2" FMT_OFF_T ":%02" FMT_OFF_T ":%02" FMT_OFF_T,
  47. h, m, s);
  48. }
  49. else {
  50. /* this equals to more than 99 hours, switch to a more suitable output
  51. format to fit within the limits. */
  52. curl_off_t d = seconds / 86400;
  53. h = (seconds - (d * 86400)) / 3600;
  54. if(d <= 999)
  55. curl_msnprintf(r, 9, "%3" FMT_OFF_T "d %02" FMT_OFF_T "h", d, h);
  56. else
  57. curl_msnprintf(r, 9, "%7" FMT_OFF_T "d", d);
  58. }
  59. }
  60. /* The point of this function would be to return a string of the input data,
  61. but never longer than 6 columns (+ one zero byte).
  62. Add suffix k, M, G when suitable... */
  63. static char *max6data(curl_off_t bytes, char *max6)
  64. {
  65. /* a signed 64-bit value is 8192 petabytes maximum */
  66. const char unit[] = { 'k', 'M', 'G', 'T', 'P', 0 };
  67. int k = 0;
  68. if(bytes < 1000000) {
  69. curl_msnprintf(max6, 7, "%5" CURL_FORMAT_CURL_OFF_T, bytes);
  70. return max6;
  71. }
  72. do {
  73. curl_off_t nbytes = bytes / 1024;
  74. if(nbytes < 1000) {
  75. /* xxx.yU */
  76. curl_msnprintf(max6, 7, "%3" CURL_FORMAT_CURL_OFF_T
  77. ".%" CURL_FORMAT_CURL_OFF_T "%c", nbytes,
  78. (bytes%1024) / (1024/10), unit[k]);
  79. break;
  80. }
  81. else if(nbytes < 100000) {
  82. /* xxxxxU */
  83. curl_msnprintf(max6, 7, "%5" CURL_FORMAT_CURL_OFF_T "%c",
  84. nbytes, unit[k]);
  85. break;
  86. }
  87. bytes = nbytes;
  88. k++;
  89. DEBUGASSERT(unit[k]);
  90. } while(unit[k]);
  91. return max6;
  92. }
  93. #endif
  94. /*
  95. New proposed interface, 9th of February 2000:
  96. pgrsStartNow() - sets start time
  97. pgrsSetDownloadSize(x) - known expected download size
  98. pgrsSetUploadSize(x) - known expected upload size
  99. pgrsSetDownloadCounter() - amount of data currently downloaded
  100. pgrsSetUploadCounter() - amount of data currently uploaded
  101. pgrsUpdate() - show progress
  102. pgrsDone() - transfer complete
  103. */
  104. int Curl_pgrsDone(struct Curl_easy *data)
  105. {
  106. int rc;
  107. data->progress.lastshow = 0;
  108. rc = Curl_pgrsUpdate(data); /* the final (forced) update */
  109. if(rc)
  110. return rc;
  111. if(!data->progress.hide && !data->progress.callback)
  112. /* only output if we do not use a progress callback and we are not
  113. * hidden */
  114. curl_mfprintf(data->set.err, "\n");
  115. data->progress.speeder_c = 0; /* reset the progress meter display */
  116. return 0;
  117. }
  118. /* reset the known transfer sizes */
  119. void Curl_pgrsResetTransferSizes(struct Curl_easy *data)
  120. {
  121. Curl_pgrsSetDownloadSize(data, -1);
  122. Curl_pgrsSetUploadSize(data, -1);
  123. }
  124. /*
  125. *
  126. * Curl_pgrsTimeWas(). Store the timestamp time at the given label.
  127. */
  128. void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer,
  129. struct curltime timestamp)
  130. {
  131. timediff_t *delta = NULL;
  132. switch(timer) {
  133. default:
  134. case TIMER_NONE:
  135. /* mistake filter */
  136. break;
  137. case TIMER_STARTOP:
  138. /* This is set at the start of a transfer */
  139. data->progress.t_startop = timestamp;
  140. data->progress.t_startqueue = timestamp;
  141. data->progress.t_postqueue = 0;
  142. break;
  143. case TIMER_STARTSINGLE:
  144. /* This is set at the start of each single transfer */
  145. data->progress.t_startsingle = timestamp;
  146. data->progress.is_t_startransfer_set = FALSE;
  147. break;
  148. case TIMER_POSTQUEUE:
  149. /* Queue time is accumulative from all involved redirects */
  150. data->progress.t_postqueue +=
  151. curlx_timediff_us(timestamp, data->progress.t_startqueue);
  152. break;
  153. case TIMER_STARTACCEPT:
  154. data->progress.t_acceptdata = timestamp;
  155. break;
  156. case TIMER_NAMELOOKUP:
  157. delta = &data->progress.t_nslookup;
  158. break;
  159. case TIMER_CONNECT:
  160. delta = &data->progress.t_connect;
  161. break;
  162. case TIMER_APPCONNECT:
  163. delta = &data->progress.t_appconnect;
  164. break;
  165. case TIMER_PRETRANSFER:
  166. delta = &data->progress.t_pretransfer;
  167. break;
  168. case TIMER_STARTTRANSFER:
  169. delta = &data->progress.t_starttransfer;
  170. /* prevent updating t_starttransfer unless:
  171. * 1) this is the first time we are setting t_starttransfer
  172. * 2) a redirect has occurred since the last time t_starttransfer was set
  173. * This prevents repeated invocations of the function from incorrectly
  174. * changing the t_starttransfer time.
  175. */
  176. if(data->progress.is_t_startransfer_set) {
  177. return;
  178. }
  179. else {
  180. data->progress.is_t_startransfer_set = TRUE;
  181. break;
  182. }
  183. case TIMER_POSTRANSFER:
  184. delta = &data->progress.t_posttransfer;
  185. break;
  186. case TIMER_REDIRECT:
  187. data->progress.t_redirect = curlx_timediff_us(timestamp,
  188. data->progress.start);
  189. data->progress.t_startqueue = timestamp;
  190. break;
  191. }
  192. if(delta) {
  193. timediff_t us = curlx_timediff_us(timestamp, data->progress.t_startsingle);
  194. if(us < 1)
  195. us = 1; /* make sure at least one microsecond passed */
  196. *delta += us;
  197. }
  198. }
  199. /*
  200. *
  201. * Curl_pgrsTime(). Store the current time at the given label. This fetches a
  202. * fresh "now" and returns it.
  203. *
  204. * @unittest: 1399
  205. */
  206. struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer)
  207. {
  208. struct curltime now = curlx_now();
  209. Curl_pgrsTimeWas(data, timer, now);
  210. return now;
  211. }
  212. void Curl_pgrsStartNow(struct Curl_easy *data)
  213. {
  214. struct Progress *p = &data->progress;
  215. p->speeder_c = 0; /* reset the progress meter display */
  216. p->start = curlx_now();
  217. p->is_t_startransfer_set = FALSE;
  218. p->ul.limit.start = p->start;
  219. p->dl.limit.start = p->start;
  220. p->ul.limit.start_size = 0;
  221. p->dl.limit.start_size = 0;
  222. p->dl.cur_size = 0;
  223. p->ul.cur_size = 0;
  224. /* the sizes are unknown at start */
  225. p->dl_size_known = FALSE;
  226. p->ul_size_known = FALSE;
  227. Curl_ratelimit(data, p->start);
  228. }
  229. /*
  230. * This is used to handle speed limits, calculating how many milliseconds to
  231. * wait until we are back under the speed limit, if needed.
  232. *
  233. * The way it works is by having a "starting point" (time & amount of data
  234. * transferred by then) used in the speed computation, to be used instead of
  235. * the start of the transfer. This starting point is regularly moved as
  236. * transfer goes on, to keep getting accurate values (instead of average over
  237. * the entire transfer).
  238. *
  239. * This function takes the current amount of data transferred, the amount at
  240. * the starting point, the limit (in bytes/s), the time of the starting point
  241. * and the current time.
  242. *
  243. * Returns 0 if no waiting is needed or when no waiting is needed but the
  244. * starting point should be reset (to current); or the number of milliseconds
  245. * to wait to get back under the speed limit.
  246. */
  247. timediff_t Curl_pgrsLimitWaitTime(struct pgrs_dir *d,
  248. curl_off_t bytes_per_sec,
  249. struct curltime now)
  250. {
  251. curl_off_t bytes = d->cur_size - d->limit.start_size;
  252. timediff_t should_ms;
  253. timediff_t took_ms;
  254. /* no limit or we did not get to any bytes yet */
  255. if(!bytes_per_sec || !bytes)
  256. return 0;
  257. /* The time it took us to have `bytes` */
  258. took_ms = curlx_timediff_ceil(now, d->limit.start);
  259. /* The time it *should* have taken us to have `bytes`
  260. * when obeying the bytes_per_sec speed_limit. */
  261. if(bytes < CURL_OFF_T_MAX/1000) {
  262. /* (1000 * bytes / (bytes / sec)) = 1000 * sec = ms */
  263. should_ms = (timediff_t) (1000 * bytes / bytes_per_sec);
  264. }
  265. else {
  266. /* very large `bytes`, first calc the seconds it should have taken.
  267. * if that is small enough, convert to milliseconds. */
  268. should_ms = (timediff_t) (bytes / bytes_per_sec);
  269. if(should_ms < TIMEDIFF_T_MAX/1000)
  270. should_ms *= 1000;
  271. else
  272. should_ms = TIMEDIFF_T_MAX;
  273. }
  274. if(took_ms < should_ms) {
  275. /* when gotten to `bytes` too fast, wait the difference */
  276. return should_ms - took_ms;
  277. }
  278. return 0;
  279. }
  280. /*
  281. * Set the number of downloaded bytes so far.
  282. */
  283. CURLcode Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
  284. {
  285. data->progress.dl.cur_size = size;
  286. return CURLE_OK;
  287. }
  288. /*
  289. * Update the timestamp and sizestamp to use for rate limit calculations.
  290. */
  291. void Curl_ratelimit(struct Curl_easy *data, struct curltime now)
  292. {
  293. /* do not set a new stamp unless the time since last update is long enough */
  294. if(data->set.max_recv_speed) {
  295. if(curlx_timediff(now, data->progress.dl.limit.start) >=
  296. MIN_RATE_LIMIT_PERIOD) {
  297. data->progress.dl.limit.start = now;
  298. data->progress.dl.limit.start_size = data->progress.dl.cur_size;
  299. }
  300. }
  301. if(data->set.max_send_speed) {
  302. if(curlx_timediff(now, data->progress.ul.limit.start) >=
  303. MIN_RATE_LIMIT_PERIOD) {
  304. data->progress.ul.limit.start = now;
  305. data->progress.ul.limit.start_size = data->progress.ul.cur_size;
  306. }
  307. }
  308. }
  309. /*
  310. * Set the number of uploaded bytes so far.
  311. */
  312. void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size)
  313. {
  314. data->progress.ul.cur_size = size;
  315. }
  316. void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size)
  317. {
  318. if(size >= 0) {
  319. data->progress.dl.total_size = size;
  320. data->progress.dl_size_known = TRUE;
  321. }
  322. else {
  323. data->progress.dl.total_size = 0;
  324. data->progress.dl_size_known = FALSE;
  325. }
  326. }
  327. void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
  328. {
  329. if(size >= 0) {
  330. data->progress.ul.total_size = size;
  331. data->progress.ul_size_known = TRUE;
  332. }
  333. else {
  334. data->progress.ul.total_size = 0;
  335. data->progress.ul_size_known = FALSE;
  336. }
  337. }
  338. void Curl_pgrsEarlyData(struct Curl_easy *data, curl_off_t sent)
  339. {
  340. data->progress.earlydata_sent = sent;
  341. }
  342. /* returns the average speed in bytes / second */
  343. static curl_off_t trspeed(curl_off_t size, /* number of bytes */
  344. curl_off_t us) /* microseconds */
  345. {
  346. if(us < 1)
  347. return size * 1000000;
  348. else if(size < CURL_OFF_T_MAX/1000000)
  349. return (size * 1000000) / us;
  350. else if(us >= 1000000)
  351. return size / (us / 1000000);
  352. else
  353. return CURL_OFF_T_MAX;
  354. }
  355. /* returns TRUE if it is time to show the progress meter */
  356. static bool progress_calc(struct Curl_easy *data, struct curltime now)
  357. {
  358. bool timetoshow = FALSE;
  359. struct Progress * const p = &data->progress;
  360. /* The time spent so far (from the start) in microseconds */
  361. p->timespent = curlx_timediff_us(now, p->start);
  362. p->dl.speed = trspeed(p->dl.cur_size, p->timespent);
  363. p->ul.speed = trspeed(p->ul.cur_size, p->timespent);
  364. /* Calculations done at most once a second, unless end is reached */
  365. if(p->lastshow != now.tv_sec) {
  366. int countindex; /* amount of seconds stored in the speeder array */
  367. int nowindex = p->speeder_c% CURR_TIME;
  368. p->lastshow = now.tv_sec;
  369. timetoshow = TRUE;
  370. /* Let's do the "current speed" thing, with the dl + ul speeds
  371. combined. Store the speed at entry 'nowindex'. */
  372. p->speeder[ nowindex ] = p->dl.cur_size + p->ul.cur_size;
  373. /* remember the exact time for this moment */
  374. p->speeder_time [ nowindex ] = now;
  375. /* advance our speeder_c counter, which is increased every time we get
  376. here and we expect it to never wrap as 2^32 is a lot of seconds! */
  377. p->speeder_c++;
  378. /* figure out how many index entries of data we have stored in our speeder
  379. array. With N_ENTRIES filled in, we have about N_ENTRIES-1 seconds of
  380. transfer. Imagine, after one second we have filled in two entries,
  381. after two seconds we have filled in three entries etc. */
  382. countindex = ((p->speeder_c >= CURR_TIME) ? CURR_TIME : p->speeder_c) - 1;
  383. /* first of all, we do not do this if there is no counted seconds yet */
  384. if(countindex) {
  385. int checkindex;
  386. timediff_t span_ms;
  387. curl_off_t amount;
  388. /* Get the index position to compare with the 'nowindex' position.
  389. Get the oldest entry possible. While we have less than CURR_TIME
  390. entries, the first entry will remain the oldest. */
  391. checkindex = (p->speeder_c >= CURR_TIME) ? p->speeder_c%CURR_TIME : 0;
  392. /* Figure out the exact time for the time span */
  393. span_ms = curlx_timediff(now, p->speeder_time[checkindex]);
  394. if(span_ms == 0)
  395. span_ms = 1; /* at least one millisecond MUST have passed */
  396. /* Calculate the average speed the last 'span_ms' milliseconds */
  397. amount = p->speeder[nowindex]- p->speeder[checkindex];
  398. if(amount > (0xffffffff/1000))
  399. /* the 'amount' value is bigger than would fit in 32 bits if
  400. multiplied with 1000, so we use the double math for this */
  401. p->current_speed = (curl_off_t)
  402. ((double)amount/((double)span_ms/1000.0));
  403. else
  404. /* the 'amount' value is small enough to fit within 32 bits even
  405. when multiplied with 1000 */
  406. p->current_speed = amount * 1000/span_ms;
  407. }
  408. else
  409. /* the first second we use the average */
  410. p->current_speed = p->ul.speed + p->dl.speed;
  411. } /* Calculations end */
  412. return timetoshow;
  413. }
  414. #ifndef CURL_DISABLE_PROGRESS_METER
  415. struct pgrs_estimate {
  416. curl_off_t secs;
  417. curl_off_t percent;
  418. };
  419. static curl_off_t pgrs_est_percent(curl_off_t total, curl_off_t cur)
  420. {
  421. if(total > 10000)
  422. return cur / (total / 100);
  423. else if(total > 0)
  424. return (cur*100) / total;
  425. return 0;
  426. }
  427. static void pgrs_estimates(struct pgrs_dir *d,
  428. bool total_known,
  429. struct pgrs_estimate *est)
  430. {
  431. est->secs = 0;
  432. est->percent = 0;
  433. if(total_known && (d->speed > 0)) {
  434. est->secs = d->total_size / d->speed;
  435. est->percent = pgrs_est_percent(d->total_size, d->cur_size);
  436. }
  437. }
  438. static void progress_meter(struct Curl_easy *data)
  439. {
  440. struct Progress *p = &data->progress;
  441. char max6[6][7];
  442. struct pgrs_estimate dl_estm;
  443. struct pgrs_estimate ul_estm;
  444. struct pgrs_estimate total_estm;
  445. curl_off_t total_cur_size;
  446. curl_off_t total_expected_size;
  447. curl_off_t dl_size;
  448. char time_left[10];
  449. char time_total[10];
  450. char time_spent[10];
  451. curl_off_t cur_secs = (curl_off_t)p->timespent/1000000; /* seconds */
  452. if(!p->headers_out) {
  453. if(data->state.resume_from) {
  454. curl_mfprintf(data->set.err,
  455. "** Resuming transfer from byte position %" FMT_OFF_T "\n",
  456. data->state.resume_from);
  457. }
  458. curl_mfprintf(data->set.err,
  459. " %% Total %% Received %% Xferd Average Speed "
  460. "Time Time Time Current\n"
  461. " Dload Upload "
  462. "Total Spent Left Speed\n");
  463. p->headers_out = TRUE; /* headers are shown */
  464. }
  465. /* Figure out the estimated time of arrival for upload and download */
  466. pgrs_estimates(&p->ul, (bool)p->ul_size_known, &ul_estm);
  467. pgrs_estimates(&p->dl, (bool)p->dl_size_known, &dl_estm);
  468. /* Since both happen at the same time, total expected duration is max. */
  469. total_estm.secs = CURLMAX(ul_estm.secs, dl_estm.secs);
  470. /* create the three time strings */
  471. time2str(time_left, total_estm.secs > 0 ? (total_estm.secs - cur_secs) : 0);
  472. time2str(time_total, total_estm.secs);
  473. time2str(time_spent, cur_secs);
  474. /* Get the total amount of data expected to get transferred */
  475. total_expected_size =
  476. p->ul_size_known ? p->ul.total_size : p->ul.cur_size;
  477. dl_size =
  478. p->dl_size_known ? p->dl.total_size : p->dl.cur_size;
  479. /* integer overflow check */
  480. if((CURL_OFF_T_MAX - total_expected_size) < dl_size)
  481. total_expected_size = CURL_OFF_T_MAX; /* capped */
  482. else
  483. total_expected_size += dl_size;
  484. /* We have transferred this much so far */
  485. total_cur_size = p->dl.cur_size + p->ul.cur_size;
  486. /* Get the percentage of data transferred so far */
  487. total_estm.percent = pgrs_est_percent(total_expected_size, total_cur_size);
  488. curl_mfprintf(data->set.err,
  489. "\r"
  490. "%3" FMT_OFF_T " %s "
  491. "%3" FMT_OFF_T " %s "
  492. "%3" FMT_OFF_T " %s %s %s %s %s %s %s",
  493. total_estm.percent, /* 3 letters */ /* total % */
  494. max6data(total_expected_size, max6[2]), /* total size */
  495. dl_estm.percent, /* 3 letters */ /* rcvd % */
  496. max6data(p->dl.cur_size, max6[0]), /* rcvd size */
  497. ul_estm.percent, /* 3 letters */ /* xfer % */
  498. max6data(p->ul.cur_size, max6[1]), /* xfer size */
  499. max6data(p->dl.speed, max6[3]), /* avrg dl speed */
  500. max6data(p->ul.speed, max6[4]), /* avrg ul speed */
  501. time_total, /* 8 letters */ /* total time */
  502. time_spent, /* 8 letters */ /* time spent */
  503. time_left, /* 8 letters */ /* time left */
  504. max6data(p->current_speed, max6[5])
  505. );
  506. /* we flush the output stream to make it appear as soon as possible */
  507. fflush(data->set.err);
  508. }
  509. #else
  510. /* progress bar disabled */
  511. #define progress_meter(x) Curl_nop_stmt
  512. #endif
  513. /*
  514. * Curl_pgrsUpdate() returns 0 for success or the value returned by the
  515. * progress callback!
  516. */
  517. static int pgrsupdate(struct Curl_easy *data, bool showprogress)
  518. {
  519. if(!data->progress.hide) {
  520. if(data->set.fxferinfo) {
  521. int result;
  522. /* There is a callback set, call that */
  523. Curl_set_in_callback(data, TRUE);
  524. result = data->set.fxferinfo(data->set.progress_client,
  525. data->progress.dl.total_size,
  526. data->progress.dl.cur_size,
  527. data->progress.ul.total_size,
  528. data->progress.ul.cur_size);
  529. Curl_set_in_callback(data, FALSE);
  530. if(result != CURL_PROGRESSFUNC_CONTINUE) {
  531. if(result)
  532. failf(data, "Callback aborted");
  533. return result;
  534. }
  535. }
  536. else if(data->set.fprogress) {
  537. int result;
  538. /* The older deprecated callback is set, call that */
  539. Curl_set_in_callback(data, TRUE);
  540. result = data->set.fprogress(data->set.progress_client,
  541. (double)data->progress.dl.total_size,
  542. (double)data->progress.dl.cur_size,
  543. (double)data->progress.ul.total_size,
  544. (double)data->progress.ul.cur_size);
  545. Curl_set_in_callback(data, FALSE);
  546. if(result != CURL_PROGRESSFUNC_CONTINUE) {
  547. if(result)
  548. failf(data, "Callback aborted");
  549. return result;
  550. }
  551. }
  552. if(showprogress)
  553. progress_meter(data);
  554. }
  555. return 0;
  556. }
  557. int Curl_pgrsUpdate(struct Curl_easy *data)
  558. {
  559. struct curltime now = curlx_now(); /* what time is it */
  560. bool showprogress = progress_calc(data, now);
  561. return pgrsupdate(data, showprogress);
  562. }
  563. /*
  564. * Update all progress, do not do progress meter/callbacks.
  565. */
  566. void Curl_pgrsUpdate_nometer(struct Curl_easy *data)
  567. {
  568. struct curltime now = curlx_now(); /* what time is it */
  569. (void)progress_calc(data, now);
  570. }