]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
service: find the tuner/source with the lowest weight for the override action
authorJaroslav Kysela <perex@perex.cz>
Tue, 10 Jun 2014 12:23:18 +0000 (14:23 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 10 Jun 2014 12:23:18 +0000 (14:23 +0200)
src/service.c

index 72558f599f6e010f2551c575dfdf453126abaa9b..01e26cb5d0042f2d15ee7f20c5bb64156f7a0d38 100644 (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 */