From a6d4e850fc1b1fa091fb0a06becb39dd07f652af Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Mon, 25 Oct 2010 14:43:38 +0300 Subject: [PATCH] Fixed EXT protocol execution (Thanks to Peter Holik). Changed scripts to use bash instead of sh. --- HISTORY | 4 +++- iptv/image.sh | 2 +- iptv/internetradio.sh | 2 +- iptv/iptvstream-notrap.sh | 2 +- iptv/iptvstream.sh | 2 +- iptv/linein.sh | 2 +- iptv/vlc2iptv | 2 +- iptv/webcam.sh | 2 +- protocolext.c | 10 +++++++--- 9 files changed, 17 insertions(+), 11 deletions(-) diff --git a/HISTORY b/HISTORY index 7a1d5b0..620ab40 100644 --- a/HISTORY +++ b/HISTORY @@ -142,7 +142,7 @@ VDR Plugin 'iptv' Revision History - Updated for vdr-1.7.15. -2010-09-19: Version 0.4.3 +2010-xx-xx: Version 0.4.3 - Updated for vdr-1.7.16. - Renamed Sid scanner to section id scanner and added @@ -152,3 +152,5 @@ VDR Plugin 'iptv' Revision History - Changed ProvidesChannel() to set the need of detaching receivers due to VDR's channel selection mechanism. - Enabled partial content responses for HTTP protocol. +- Fixed EXT protocol execution (Thanks to Peter Holik). +- Changed scripts to use bash instead of sh. diff --git a/iptv/image.sh b/iptv/image.sh index 9938089..4d04c98 100755 --- a/iptv/image.sh +++ b/iptv/image.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e diff --git a/iptv/internetradio.sh b/iptv/internetradio.sh index d338b52..72dc4a4 100755 --- a/iptv/internetradio.sh +++ b/iptv/internetradio.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # internetradio.sh is used by the VDR iptv plugin to transcode an internet # radio stream. diff --git a/iptv/iptvstream-notrap.sh b/iptv/iptvstream-notrap.sh index 3ec440f..98c7277 100755 --- a/iptv/iptvstream-notrap.sh +++ b/iptv/iptvstream-notrap.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # iptvstream.sh can be used by the VDR iptv plugin to transcode external # sources diff --git a/iptv/iptvstream.sh b/iptv/iptvstream.sh index 1f69a4a..5c46b7b 100755 --- a/iptv/iptvstream.sh +++ b/iptv/iptvstream.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # iptvstream.sh can be used by the VDR iptv plugin to transcode external # sources diff --git a/iptv/linein.sh b/iptv/linein.sh index cdaf863..aacfa80 100755 --- a/iptv/linein.sh +++ b/iptv/linein.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # linein.sh is used by the VDR iptv plugin to transcode line-in of # a soundcard. diff --git a/iptv/vlc2iptv b/iptv/vlc2iptv index 01405f7..aae6f66 100755 --- a/iptv/vlc2iptv +++ b/iptv/vlc2iptv @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # vlc2iptv is used by the VDR iptv plugin to transcode external sources # diff --git a/iptv/webcam.sh b/iptv/webcam.sh index 979c540..19054ba 100755 --- a/iptv/webcam.sh +++ b/iptv/webcam.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # webcam.sh is used by the VDR iptv plugin to transcode an internet radio # stream remuxed with images (e.g. webcam) to provide a video stream. diff --git a/protocolext.c b/protocolext.c index 955d6c2..c42449c 100644 --- a/protocolext.c +++ b/protocolext.c @@ -38,6 +38,8 @@ void cIptvProtocolExt::ExecuteScript(void) { debug("cIptvProtocolExt::ExecuteScript()\n"); // Check if already executing + if (isActive || isempty(scriptFile)) + return; if (pid > 0) { error("Cannot execute script!"); return; @@ -53,7 +55,7 @@ void cIptvProtocolExt::ExecuteScript(void) // Execute the external script cString cmd = cString::sprintf("%s %d %d", *scriptFile, scriptParameter, socketPort); debug("cIptvProtocolExt::ExecuteScript(child): %s\n", *cmd); - if (execl("/bin/sh", "sh", "-c", *cmd, (char *)NULL) == -1) { + if (execl("/bin/bash", "sh", "-c", *cmd, (char *)NULL) == -1) { error("Script execution failed: %s", *cmd); _exit(-1); } @@ -67,6 +69,8 @@ void cIptvProtocolExt::ExecuteScript(void) void cIptvProtocolExt::TerminateScript(void) { debug("cIptvProtocolExt::TerminateScript(): pid=%d\n", pid); + if (!isActive || isempty(scriptFile)) + return; if (pid > 0) { const unsigned int timeoutms = 100; unsigned int waitms = 0; @@ -119,11 +123,11 @@ bool cIptvProtocolExt::Open(void) bool cIptvProtocolExt::Close(void) { debug("cIptvProtocolExt::Close()\n"); - // Close the socket - CloseSocket(); // Terminate the external script TerminateScript(); isActive = false; + // Close the socket + CloseSocket(); return true; }