From: Jaroslav Kysela Date: Sun, 14 Jan 2018 20:33:09 +0000 (+0100) Subject: IPTV: fix the tvhpoll cache behaviour - unregister file descriptors correctly, fixes... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=df1c5c55404842b5f1a12d2e8f9a15fd349ead22;p=thirdparty%2Ftvheadend.git IPTV: fix the tvhpoll cache behaviour - unregister file descriptors correctly, fixes #4838 --- diff --git a/src/input/mpegts/iptv/iptv.c b/src/input/mpegts/iptv/iptv.c index 547f76293..5707a2a22 100644 --- a/src/input/mpegts/iptv/iptv.c +++ b/src/input/mpegts/iptv/iptv.c @@ -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; } diff --git a/src/input/mpegts/iptv/iptv_pipe.c b/src/input/mpegts/iptv/iptv_pipe.c index f75b1676e..6f4265dd7 100644 --- a/src/input/mpegts/iptv/iptv_pipe.c +++ b/src/input/mpegts/iptv/iptv_pipe.c @@ -20,6 +20,7 @@ #include "tvheadend.h" #include "iptv_private.h" #include "spawn.h" +#include "tvhpoll.h" #include #include @@ -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); diff --git a/src/input/mpegts/iptv/iptv_private.h b/src/input/mpegts/iptv/iptv_private.h index 42a37be1f..6a1893350 100644 --- a/src/input/mpegts/iptv/iptv_private.h +++ b/src/input/mpegts/iptv/iptv_private.h @@ -29,14 +29,14 @@ #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 );