From: Jaroslav Kysela Date: Fri, 26 Feb 2016 20:15:23 +0000 (+0100) Subject: service subscription: improve the input selection in busy condition X-Git-Tag: v4.2.1~978 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6317159a94c68300302f947b2b69ce2e73dd58f6;p=thirdparty%2Ftvheadend.git service subscription: improve the input selection in busy condition --- diff --git a/src/service.c b/src/service.c index c96a956fb..8fdc694ce 100644 --- a/src/service.c +++ b/src/service.c @@ -697,7 +697,7 @@ service_find_instance idnode_list_mapping_t *ilm; service_instance_t *si, *next; profile_t *pro = prch ? prch->prch_pro : NULL; - int enlisted, weight2; + int enlisted; lock_assert(&global_lock); @@ -775,15 +775,20 @@ service_find_instance break; } - /* Bump the one with lowest weight */ + /* Bump the one with lowest weight or bigger priority */ if (!si) { next = NULL; - weight2 = weight; - TAILQ_FOREACH(si, sil, si_link) - if (weight2 > si->si_weight && si->si_error == 0) { - weight2 = si->si_weight; - next = si; + TAILQ_FOREACH(si, sil, si_link) { + if (si->si_error) continue; + if (next == NULL) { + if (si->si_weight < weight) + next = si; + } else { + if ((si->si_weight < next->si_weight) || + (si->si_weight == next->si_weight && si->si_prio > next->si_prio)) + next = si; } + } si = next; }