Skip to content

Commit

Permalink
Add sleep when all mirrors were tried (RhBug:1741931)
Browse files Browse the repository at this point in the history
It resolves the problem when only one mirror or URL is available but it
is temporary down. Before second try it will sleep for 1 seconds, then
2s and before third (the last try) 3s.

https://bugzilla.redhat.com/show_bug.cgi?id=1741931
  • Loading branch information
j-mracek authored and Conan-Kudo committed Sep 7, 2019
1 parent 071d824 commit 2cbe270
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion librepo/downloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#include "url_substitution.h"
#include "yum_internal.h"

#include <unistd.h>

volatile sig_atomic_t lr_interrupt = 0;

void
Expand Down Expand Up @@ -702,12 +704,17 @@ select_suitable_mirror(LrDownload *dd,

*selected_mirror = NULL;
// mirrors_iterated is used to allow to use mirrors multiple times for a target
int mirrors_iterated = 0;
unsigned mirrors_iterated = 0;
// Iterate over mirrors for the target. If no suitable mirror is found on
// the first iteration, relax the conditions (by allowing previously
// failing mirrors to be used again) and do additional iterations up to
// number af allowed failures equal to dd->allowed_mirror_failures.
do {
// Sleep when all mirrors were alredy tried
// It prevents to call same url inmediatly after fail
if (mirrors_iterated) {
sleep(mirrors_iterated);
}
// Iterate over mirror for the target
for (GSList *elem = target->lrmirrors; elem; elem = g_slist_next(elem)) {
LrMirror *c_mirror = elem->data;
Expand Down

0 comments on commit 2cbe270

Please sign in to comment.