diff options
author | Mole Shang <[email protected]> | 2024-03-02 12:53:05 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2024-03-02 12:53:05 +0800 |
commit | 62c193bd4e464ec9d847b8abff21e10dfc7b511e (patch) | |
tree | 30adea8012d823aa884b05d1a5b93cbe0e56ee55 | |
parent | f4309930b547aa845f2f12824109fb606d9fb217 (diff) | |
download | hinata-62c193bd4e464ec9d847b8abff21e10dfc7b511e.tar.gz hinata-62c193bd4e464ec9d847b8abff21e10dfc7b511e.tar.bz2 hinata-62c193bd4e464ec9d847b8abff21e10dfc7b511e.zip |
process_url: do not update curl status during callback
... and in turn fixes the race condition
-rw-r--r-- | src/process_url.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/process_url.c b/src/process_url.c index a8dadc9..c1d8d38 100644 --- a/src/process_url.c +++ b/src/process_url.c @@ -528,8 +528,10 @@ void poll_status(status_t *stat) { for (unsigned char i = 0; i < curl_conf->total_thrd; i++) { curl_conf->dlnow += curl_conf->dlnow_per_thrd[i]; } - stat->cur = (unsigned long long)curl_conf->dlnow; - stat->total = (unsigned long long)curl_conf->dltotal; + if (stat->type == SIZE_BYTES) { + stat->cur = (unsigned long long)curl_conf->dlnow; + stat->total = (unsigned long long)curl_conf->dltotal; + } DEBUG_PRINT("success_thrd: %hhu, total_thrd: %hhu, is_done: %s\n", curl_conf->success_thrd, curl_conf->total_thrd, stat->is_done ? "yes" : "no"); |