]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
IPTV: take network limits for all IPTV threads, fixes #4970
authorJaroslav Kysela <perex@perex.cz>
Sun, 25 Feb 2018 17:53:29 +0000 (18:53 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 25 Feb 2018 17:53:29 +0000 (18:53 +0100)
src/input/mpegts/iptv/iptv.c

index e7afd7eb1fbd83b4a6bd90db3071558316ffb0fe..d2df4511fc0bff2e187f760ed466fc98933b86c2 100644 (file)
@@ -147,19 +147,24 @@ iptv_input_is_free ( mpegts_input_t *mi, mpegts_mux_t *mm,
 {
   int h = 0, l = 0, w, rw = INT_MAX;
   mpegts_mux_instance_t *mmi, *rmmi = NULL;
+  iptv_input_t *mi2;
   iptv_network_t *in = (iptv_network_t *)mm->mm_network;
+  iptv_thread_pool_t *pool;
   
-  pthread_mutex_lock(&mi->mi_output_lock);
-  LIST_FOREACH(mmi, &mi->mi_mux_active, mmi_active_link)
-    if (mmi->mmi_mux->mm_network == (mpegts_network_t *)in) {
-      w = mpegts_mux_instance_weight(mmi);
-      if (w < rw && (!conf->active || mmi->mmi_mux != mm)) {
-        rmmi = mmi;
-        rw = w;
+  TAILQ_FOREACH(pool, &iptv_tpool, link) {
+    mi2 = pool->input;
+    pthread_mutex_lock(&mi2->mi_output_lock);
+    LIST_FOREACH(mmi, &mi2->mi_mux_active, mmi_active_link)
+      if (mmi->mmi_mux->mm_network == (mpegts_network_t *)in) {
+        w = mpegts_mux_instance_weight(mmi);
+        if (w < rw && (!conf->active || mmi->mmi_mux != mm)) {
+          rmmi = mmi;
+          rw = w;
+        }
+        if (w >= weight) h++; else l++;
       }
-      if (w >= weight) h++; else l++;
-    }
-  pthread_mutex_unlock(&mi->mi_output_lock);
+    pthread_mutex_unlock(&mi2->mi_output_lock);
+  }
 
   tvhtrace(LS_IPTV_SUB, "is free[%p]: h = %d, l = %d, rw = %d", mm, h, l, rw);