src/tvhlog.c \
src/idnode.c \
src/prop.c \
+ src/proplib.c \
src/utils.c \
src/wrappers.c \
src/access.c \
return iptv_url_set(&im->mm_iptv_url, &im->mm_iptv_url_sane, v, 1, 1);
}
-static htsmsg_t *
-iptv_muxdvr_class_kill_list ( void *o, const char *lang )
-{
- static const struct strtab tab[] = {
- { N_("SIGKILL"), IPTV_KILL_KILL },
- { N_("SIGTERM"), IPTV_KILL_TERM },
- { N_("SIGINT"), IPTV_KILL_INT, },
- { N_("SIGHUP"), IPTV_KILL_HUP },
- { N_("SIGUSR1"), IPTV_KILL_USR1 },
- { N_("SIGUSR2"), IPTV_KILL_USR2 },
- };
- return strtab2htsmsg(tab, 1, lang);
-}
-
const idclass_t iptv_mux_class =
{
.ic_super = &mpegts_mux_class,
.id = "iptv_kill",
.name = N_("Kill signal (pipe)"),
.off = offsetof(iptv_mux_t, mm_iptv_kill),
- .list = iptv_muxdvr_class_kill_list,
+ .list = proplib_kill_list,
.opts = PO_EXPERT
},
{
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
-#include <signal.h>
#include <assert.h>
/*
return -1;
}
-static int
-iptv_pipe_kill_sig(iptv_mux_t *im)
-{
- switch (im->mm_iptv_kill) {
- case IPTV_KILL_TERM: return SIGTERM;
- case IPTV_KILL_INT: return SIGINT;
- case IPTV_KILL_HUP: return SIGHUP;
- case IPTV_KILL_USR1: return SIGUSR1;
- case IPTV_KILL_USR2: return SIGUSR2;
- }
- return SIGKILL;
-}
-
static void
iptv_pipe_stop
( iptv_mux_t *im )
{
int rd = im->mm_iptv_fd;
pid_t pid = (intptr_t)im->im_data;
- spawn_kill(pid, iptv_pipe_kill_sig(im), im->mm_iptv_kill_timeout);
+ spawn_kill(pid, tvh_kill_to_sig(im->mm_iptv_kill), im->mm_iptv_kill_timeout);
if (rd > 0)
close(rd);
im->mm_iptv_fd = -1;
if (r <= 0) {
close(rd);
pid = (intptr_t)im->im_data;
- spawn_kill(pid, iptv_pipe_kill_sig(im), im->mm_iptv_kill_timeout);
+ spawn_kill(pid, tvh_kill_to_sig(im->mm_iptv_kill), im->mm_iptv_kill_timeout);
im->mm_iptv_fd = -1;
im->im_data = NULL;
if (mclk() < im->mm_iptv_respawn_last + sec2mono(2)) {
#define IPTV_PKTS 32
#define IPTV_PKT_PAYLOAD 1472
-#define IPTV_KILL_KILL 0
-#define IPTV_KILL_TERM 1
-#define IPTV_KILL_INT 2
-#define IPTV_KILL_HUP 3
-#define IPTV_KILL_USR1 4
-#define IPTV_KILL_USR2 5
-
extern pthread_mutex_t iptv_lock;
typedef struct iptv_input iptv_input_t;
int m_rewrite_eit;
char *m_cmdline;
char *m_mime;
+ int m_killsig;
+ int m_killtimeout;
} pass;
struct {
int m_dvbsub_reorder;
pass_muxer_t *pm = (pass_muxer_t*)m;
if(pm->pm_spawn_pid > 0)
- spawn_kill(pm->pm_spawn_pid, SIGTERM, 15);
+ spawn_kill(pm->pm_spawn_pid, tvh_kill_to_sig(pm->m_config.u.pass.m_killsig),
+ pm->m_config.u.pass.m_killtimeout);
if(pm->pm_seekable && close(pm->pm_ofd)) {
pm->pm_error = errno;
tvherror(LS_PASS, "%s: Unable to close file, close failed -- %s",
profile_t;
char *pro_cmdline;
char *pro_mime;
+ int pro_killsig;
+ int pro_killtimeout;
} profile_mpegts_spawn_t;
const idclass_t profile_mpegts_spawn_class =
.off = offsetof(profile_mpegts_spawn_t, pro_mime),
.group = 2
},
+ {
+ .type = PT_INT,
+ .id = "killsig",
+ .name = N_("Kill signal (pipe)"),
+ .off = offsetof(profile_mpegts_spawn_t, pro_killsig),
+ .list = proplib_kill_list,
+ .opts = PO_EXPERT,
+ .def.i = TVH_KILL_TERM,
+ .group = 2
+ },
+ {
+ .type = PT_INT,
+ .id = "kill_timeout",
+ .name = N_("Kill timeout (pipe/secs)"),
+ .off = offsetof(profile_mpegts_spawn_t, pro_killtimeout),
+ .opts = PO_EXPERT,
+ .def.i = 15,
+ .group = 2
+ },
{ }
}
};
c.u.pass.m_rewrite_eit = 1;
mystrset(&c.u.pass.m_cmdline, pro->pro_cmdline);
mystrset(&c.u.pass.m_mime, pro->pro_mime);
+ c.u.pass.m_killsig = pro->pro_killsig;
+ c.u.pass.m_killtimeout = pro->pro_killtimeout;
assert(!prch->prch_muxer);
prch->prch_muxer = muxer_create(&c);
pro->pro_free = profile_mpegts_spawn_free;
pro->pro_reopen = profile_mpegts_spawn_reopen;
pro->pro_open = profile_mpegts_spawn_open;
+ pro->pro_killsig = TVH_KILL_TERM;
+ pro->pro_killtimeout = 15;
return (profile_t *)pro;
}
{ return prop_md_doc(tvh_doc_##name##_property, lang); }
+/* helpers */
+htsmsg_t *proplib_kill_list ( void *o, const char *lang );
+
#endif /* __TVH_PROP_H__ */
/******************************************************************************
--- /dev/null
+/*
+ * Tvheadend - property system library (part of idnode)
+ *
+ * Copyright (C) 2017 Jaroslav Kysela
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "tvheadend.h"
+#include "prop.h"
+#include "tvh_locale.h"
+#include "lang_str.h"
+
+htsmsg_t *
+proplib_kill_list ( void *o, const char *lang )
+{
+ static const struct strtab tab[] = {
+ { N_("SIGKILL"), TVH_KILL_KILL },
+ { N_("SIGTERM"), TVH_KILL_TERM },
+ { N_("SIGINT"), TVH_KILL_INT, },
+ { N_("SIGHUP"), TVH_KILL_HUP },
+ { N_("SIGUSR1"), TVH_KILL_USR1 },
+ { N_("SIGUSR2"), TVH_KILL_USR2 },
+ };
+ return strtab2htsmsg(tab, 1, lang);
+}
TAILQ_HEAD(th_pktref_queue, th_pktref);
LIST_HEAD(streaming_target_list, streaming_target);
+/**
+ *
+ */
+#define TVH_KILL_KILL 0
+#define TVH_KILL_TERM 1
+#define TVH_KILL_INT 2
+#define TVH_KILL_HUP 3
+#define TVH_KILL_USR1 4
+#define TVH_KILL_USR2 5
+
+int tvh_kill_to_sig(int tvh_kill);
+
/**
* Stream component types
*/
#include <dirent.h>
#include <unistd.h>
#include <ctype.h>
+#include <signal.h>
#include <net/if.h>
#include <openssl/sha.h>
strftime(buf, buflen, "%F;%T(%z)", &tm);
return buf;
}
+
+int
+tvh_kill_to_sig(int tvh_kill)
+{
+ switch (tvh_kill) {
+ case TVH_KILL_TERM: return SIGTERM;
+ case TVH_KILL_INT: return SIGINT;
+ case TVH_KILL_HUP: return SIGHUP;
+ case TVH_KILL_USR1: return SIGUSR1;
+ case TVH_KILL_USR2: return SIGUSR2;
+ }
+ return SIGKILL;
+}