include retries and signatures in download count
Fixes: FS#69881 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
4bf7aa119d
commit
9060058393
1 changed files with 8 additions and 10 deletions
|
@ -456,7 +456,7 @@ static int curl_retry_next_server(CURLM *curlm, CURL *curl, struct dload_payload
|
||||||
* Returns -2 if an error happened for an optional file
|
* Returns -2 if an error happened for an optional file
|
||||||
*/
|
*/
|
||||||
static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
|
static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
|
||||||
const char *localpath)
|
const char *localpath, int *active_downloads_num)
|
||||||
{
|
{
|
||||||
alpm_handle_t *handle = NULL;
|
alpm_handle_t *handle = NULL;
|
||||||
struct dload_payload *payload = NULL;
|
struct dload_payload *payload = NULL;
|
||||||
|
@ -499,6 +499,7 @@ static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
|
||||||
server_soft_error(handle, payload->fileurl);
|
server_soft_error(handle, payload->fileurl);
|
||||||
}
|
}
|
||||||
if(curl_retry_next_server(curlm, curl, payload) == 0) {
|
if(curl_retry_next_server(curlm, curl, payload) == 0) {
|
||||||
|
(*active_downloads_num)++;
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -525,6 +526,7 @@ static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
|
||||||
payload->remote_name, hostname, payload->error_buffer);
|
payload->remote_name, hostname, payload->error_buffer);
|
||||||
server_hard_error(handle, payload->fileurl);
|
server_hard_error(handle, payload->fileurl);
|
||||||
if(curl_retry_next_server(curlm, curl, payload) == 0) {
|
if(curl_retry_next_server(curlm, curl, payload) == 0) {
|
||||||
|
(*active_downloads_num)++;
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -546,6 +548,7 @@ static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
|
||||||
payload->remote_name, hostname, payload->error_buffer);
|
payload->remote_name, hostname, payload->error_buffer);
|
||||||
}
|
}
|
||||||
if(curl_retry_next_server(curlm, curl, payload) == 0) {
|
if(curl_retry_next_server(curlm, curl, payload) == 0) {
|
||||||
|
(*active_downloads_num)++;
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -613,6 +616,7 @@ static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
|
||||||
sig->max_size = 16 * 1024;
|
sig->max_size = 16 * 1024;
|
||||||
|
|
||||||
curl_add_payload(handle, curlm, sig, localpath);
|
curl_add_payload(handle, curlm, sig, localpath);
|
||||||
|
(*active_downloads_num)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* time condition was met and we didn't download anything. we need to
|
/* time condition was met and we didn't download anything. we need to
|
||||||
|
@ -789,12 +793,11 @@ static int curl_download_internal(alpm_handle_t *handle,
|
||||||
const char *localpath)
|
const char *localpath)
|
||||||
{
|
{
|
||||||
int active_downloads_num = 0;
|
int active_downloads_num = 0;
|
||||||
bool recheck_downloads = false;
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int max_streams = handle->parallel_downloads;
|
int max_streams = handle->parallel_downloads;
|
||||||
CURLM *curlm = handle->curlm;
|
CURLM *curlm = handle->curlm;
|
||||||
|
|
||||||
while(active_downloads_num > 0 || payloads || recheck_downloads) {
|
while(active_downloads_num > 0 || payloads) {
|
||||||
CURLMcode mc;
|
CURLMcode mc;
|
||||||
|
|
||||||
for(; active_downloads_num < max_streams && payloads; active_downloads_num++) {
|
for(; active_downloads_num < max_streams && payloads; active_downloads_num++) {
|
||||||
|
@ -828,7 +831,6 @@ static int curl_download_internal(alpm_handle_t *handle,
|
||||||
err = -1;
|
err = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
recheck_downloads = false;
|
|
||||||
while(true) {
|
while(true) {
|
||||||
int msgs_left = 0;
|
int msgs_left = 0;
|
||||||
CURLMsg *msg = curl_multi_info_read(curlm, &msgs_left);
|
CURLMsg *msg = curl_multi_info_read(curlm, &msgs_left);
|
||||||
|
@ -836,7 +838,8 @@ static int curl_download_internal(alpm_handle_t *handle,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(msg->msg == CURLMSG_DONE) {
|
if(msg->msg == CURLMSG_DONE) {
|
||||||
int ret = curl_check_finished_download(curlm, msg, localpath);
|
int ret = curl_check_finished_download(curlm, msg,
|
||||||
|
localpath, &active_downloads_num);
|
||||||
if(ret == -1) {
|
if(ret == -1) {
|
||||||
/* if current payload failed to download then stop adding new payloads but wait for the
|
/* if current payload failed to download then stop adding new payloads but wait for the
|
||||||
* current ones
|
* current ones
|
||||||
|
@ -844,11 +847,6 @@ static int curl_download_internal(alpm_handle_t *handle,
|
||||||
payloads = NULL;
|
payloads = NULL;
|
||||||
err = -1;
|
err = -1;
|
||||||
}
|
}
|
||||||
/* curl_multi_check_finished_download() might add more payloads e.g. in case of a retry
|
|
||||||
* from the next mirror. We need to execute curl_multi_perform() at least one more time
|
|
||||||
* to make sure new payload requests are processed.
|
|
||||||
*/
|
|
||||||
recheck_downloads = true;
|
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(handle, ALPM_LOG_ERROR, _("curl transfer error: %d\n"), msg->msg);
|
_alpm_log(handle, ALPM_LOG_ERROR, _("curl transfer error: %d\n"), msg->msg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue