]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
epggrab: ota - improve the mux scheduler on busy situation 430/head
authorJaroslav Kysela <perex@perex.cz>
Fri, 4 Jul 2014 15:35:54 +0000 (17:35 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 7 Jul 2014 14:41:53 +0000 (16:41 +0200)
Queue only inactive ota muxes in all situations to not block
the scan on free tuners.

src/epggrab/otamux.c

index 56bd589137fdff53cbdeba979164ebc151408086..158f25bb2570bf3ebd4b8512a20301415f354099 100644 (file)
@@ -95,22 +95,39 @@ epggrab_ota_timeout_get ( void )
   return timeout;
 }
 
+static void
+epggrab_ota_requeue ( void )
+{
+  epggrab_ota_mux_t *om, *om2;
+
+  /*
+   * enqueue all muxes, but ommit the delayed ones (active+pending)
+   */
+  RB_FOREACH(om, &epggrab_ota_all, om_global_link) {
+    TAILQ_FOREACH(om2, &epggrab_ota_active, om_q_link)
+      if (om2 == om)
+        break;
+    if (om2 == om) continue;
+    TAILQ_FOREACH(om2, &epggrab_ota_pending, om_q_link)
+      if (om2 == om)
+        break;
+    if (om2 == om) continue;
+    TAILQ_INSERT_TAIL(&epggrab_ota_pending, om, om_q_link);
+  }
+}
+
 static void
 epggrab_ota_kick ( int delay )
 {
-  epggrab_ota_mux_t *om;
-
-  if (TAILQ_EMPTY(&epggrab_ota_pending) &&
-      TAILQ_EMPTY(&epggrab_ota_active)) {
-    /* next round is pending? queue all ota muxes */
-    if (epggrab_ota_pending_flag) {
-      epggrab_ota_pending_flag = 0;
-      RB_FOREACH(om, &epggrab_ota_all, om_global_link)
-        TAILQ_INSERT_TAIL(&epggrab_ota_pending, om, om_q_link);
-    } else {
-      return;
-    }
+  /* next round is pending? queue rest of ota muxes */
+  if (epggrab_ota_pending_flag) {
+    epggrab_ota_pending_flag = 0;
+    epggrab_ota_requeue();
   }
+
+  if (TAILQ_EMPTY(&epggrab_ota_pending))
+    return;
+
   gtimer_arm(&epggrab_ota_kick_timer, epggrab_ota_kick_cb, NULL, delay);
 }
 
@@ -436,12 +453,7 @@ epggrab_ota_start_cb ( void *p )
 
   epggrab_ota_pending_flag = 1;
 
-  /* Finish previous job? */
-  if (TAILQ_EMPTY(&epggrab_ota_pending) &&
-      TAILQ_EMPTY(&epggrab_ota_active)) {
-    tvhtrace("epggrab", "ota - idle - kicked");
-    epggrab_ota_kick(1);
-  }
+  epggrab_ota_kick(1);
 
   pthread_mutex_lock(&epggrab_ota_mutex);
   if (!cron_multi_next(epggrab_ota_cron_multi, dispatch_clock, &next)) {