From: Jaroslav Kysela Date: Tue, 10 Jun 2014 12:23:18 +0000 (+0200) Subject: service: find the tuner/source with the lowest weight for the override action X-Git-Tag: v4.1~1950 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92ca7963f23e9dfe900b1fd32613ea09af491d52;p=thirdparty%2Ftvheadend.git service: find the tuner/source with the lowest weight for the override action --- diff --git a/src/service.c b/src/service.c index 72558f599..01e26cb5d 100644 --- a/src/service.c +++ b/src/service.c @@ -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 */