service: find the tuner/source with the lowest weight for the override action

This commit is contained in:
Jaroslav Kysela 2014-06-10 14:23:18 +02:00
parent 8d9608b611
commit 92ca7963f2

View file

@ -528,6 +528,7 @@ service_find_instance
{
channel_service_mapping_t *csm;
service_instance_t *si, *next;
int weight2;
lock_assert(&global_lock);
@ -579,11 +580,16 @@ service_find_instance
break;
}
/* Bump someone */
/* Bump the one with lowest weight */
if (!si) {
next = NULL;
weight2 = weight;
TAILQ_FOREACH(si, sil, si_link)
if (weight > si->si_weight && si->si_error == 0)
break;
if (weight2 > si->si_weight && si->si_error == 0) {
weight2 = si->si_weight;
next = si;
}
si = next;
}
/* Failed */