]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
service: handle input priority better
authorJaroslav Kysela <perex@perex.cz>
Mon, 26 May 2014 11:09:23 +0000 (13:09 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 10 Jun 2014 12:14:46 +0000 (14:14 +0200)
Ensure, that inputs with higher priorities are preferred.
The decision line is:

1) re-use input if the in-use mux matches
2) use a free input with highest priority
3) cancel the mux/input with smallest weight and use it for new

src/service.c

index c797041d963a5ae813f9df4054a019048f2f3540..72558f599f6e010f2551c575dfdf453126abaa9b 100644 (file)
@@ -567,14 +567,21 @@ service_find_instance
       return si;
     }
 
-  /* Forced or Idle */
+  /* Forced */
   TAILQ_FOREACH(si, sil, si_link)
-    if(si->si_weight <= 0 && si->si_error == 0)
+    if(si->si_weight < 0 && si->si_error == 0)
       break;
 
-  /* Bump someone */
+  /* Idle */
   if (!si) {
     TAILQ_FOREACH_REVERSE(si, sil, service_instance_list, si_link)
+      if (si->si_weight == 0 && si->si_error == 0)
+        break;
+  }
+
+  /* Bump someone */
+  if (!si) {
+    TAILQ_FOREACH(si, sil, si_link)
       if (weight > si->si_weight && si->si_error == 0)
         break;
   }