]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
mpegts: tables - add mutex protection to mpegts_table_add()
authorJaroslav Kysela <perex@perex.cz>
Fri, 11 Jul 2014 14:28:22 +0000 (16:28 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 11 Jul 2014 14:28:22 +0000 (16:28 +0200)
src/input/mpegts/mpegts_table.c

index c3b6f7bbcf7d982c337b6dcc148cb188b95c1138..b4c0c258988b8590ecb76ebe4dc343b10de1f323 100644 (file)
@@ -136,6 +136,7 @@ mpegts_table_add
   int subscribe = 1;
 
   /* Check for existing */
+  pthread_mutex_lock(&mm->mm_tables_lock);
   LIST_FOREACH(mt, &mm->mm_tables, mt_link) {
     if (mt->mt_opaque != opaque)
       continue;
@@ -154,11 +155,16 @@ mpegts_table_add
     } else {
       if (strcmp(mt->mt_name, name))
         continue;
-      if (!(flags & MT_SKIPSUBS) && !mt->mt_subscribed)
+      if (!(flags & MT_SKIPSUBS) && !mt->mt_subscribed) {
+        pthread_mutex_unlock(&mm->mm_tables_lock);
         mm->mm_open_table(mm, mt, 1);
+        return mt;
+      }
     }
+    pthread_mutex_unlock(&mm->mm_tables_lock);
     return mt;
   }
+  pthread_mutex_unlock(&mm->mm_tables_lock);
 
   tvhtrace("mpegts", "add %s table %02X/%02X (%d) pid %04X (%d)",
            name, tableid, mask, tableid, pid, pid);