]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
IPTV: fix the tvhpoll cache behaviour - unregister file descriptors correctly, fixes...
authorJaroslav Kysela <perex@perex.cz>
Sun, 14 Jan 2018 20:33:09 +0000 (21:33 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 14 Jan 2018 20:33:09 +0000 (21:33 +0100)
src/input/mpegts/iptv/iptv.c
src/input/mpegts/iptv/iptv_pipe.c
src/input/mpegts/iptv/iptv_private.h

index 547f76293e7791bc3b30cc10a311a8c64bf23f94..5707a2a22df608b68e94ba456682e9c9ce2ce602 100644 (file)
@@ -368,14 +368,16 @@ iptv_input_stop_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi )
 
   /* Close file */
   if (im->mm_iptv_fd > 0) {
-    udp_close(im->mm_iptv_connection); // removes from poll
+    tvhpoll_rem1(iptv_poll, im->mm_iptv_fd);
+    udp_close(im->mm_iptv_connection);
     im->mm_iptv_connection = NULL;
     im->mm_iptv_fd = -1;
   }
 
   /* Close file2 */
   if (im->mm_iptv_fd2 > 0) {
-    udp_close(im->mm_iptv_connection2); // removes from poll
+    tvhpoll_rem1(iptv_poll, im->mm_iptv_fd2);
+    udp_close(im->mm_iptv_connection2);
     im->mm_iptv_connection2 = NULL;
     im->mm_iptv_fd2 = -1;
   }
index f75b1676eb1c2895c0952833a4632fce3cbb4629..6f4265dd788fa15139c14e5e64fcbea0b9cc2749 100644 (file)
@@ -20,6 +20,7 @@
 #include "tvheadend.h"
 #include "iptv_private.h"
 #include "spawn.h"
+#include "tvhpoll.h"
 
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -82,8 +83,10 @@ iptv_pipe_stop
   int rd = im->mm_iptv_fd;
   pid_t pid = (intptr_t)im->im_data;
   spawn_kill(pid, tvh_kill_to_sig(im->mm_iptv_kill), im->mm_iptv_kill_timeout);
-  if (rd > 0)
+  if (rd > 0) {
+    tvhpoll_rem1(iptv_poll, rd);
     close(rd);
+  }
   im->mm_iptv_fd = -1;
 }
 
@@ -104,6 +107,7 @@ iptv_pipe_read ( iptv_mux_t *im )
         continue;
     }
     if (r <= 0) {
+      tvhpoll_rem1(iptv_poll, rd);
       close(rd);
       pid = (intptr_t)im->im_data;
       spawn_kill(pid, tvh_kill_to_sig(im->mm_iptv_kill), im->mm_iptv_kill_timeout);
index 42a37be1fc7a60bed2a38fd1b3a5177cabab6dd1..6a1893350ca287a7acaf488e83202e54b94028a2 100644 (file)
 #define IPTV_PKTS        32
 #define IPTV_PKT_PAYLOAD 1472
 
-extern pthread_mutex_t iptv_lock;
-
 typedef struct iptv_input   iptv_input_t;
 typedef struct iptv_network iptv_network_t;
 typedef struct iptv_mux     iptv_mux_t;
 typedef struct iptv_service iptv_service_t;
 typedef struct iptv_handler iptv_handler_t;
 
+typedef struct tvhpoll tvhpoll_t;
+
 struct iptv_handler
 {
   const char *scheme;
@@ -180,6 +180,8 @@ extern const idclass_t iptv_mux_class;
 extern iptv_input_t   *iptv_input;
 extern iptv_network_t *iptv_network;
 
+extern pthread_mutex_t iptv_lock;
+extern tvhpoll_t      *iptv_poll;
 
 int iptv_url_set ( char **url, char **sane_url, const char *str, int allow_file, int allow_pipe );