summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2004-11-27 10:28:51 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2004-11-27 10:28:51 +0100
commit69ecb6a4d8d7eb73bd81f690d8e153a7cc6b882e (patch)
treefe56a71b801b607c638ecbc79612bc2136ce3c9d
parenta05ed0363139694d1b4eece5ea54346de64265e1 (diff)
downloadvdr-69ecb6a4d8d7eb73bd81f690d8e153a7cc6b882e.tar.gz
vdr-69ecb6a4d8d7eb73bd81f690d8e153a7cc6b882e.tar.bz2
Fixed a possible race condition in generating the DVB device names
-rw-r--r--CONTRIBUTORS1
-rw-r--r--HISTORY2
-rw-r--r--dvbdevice.c25
3 files changed, 17 insertions, 11 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index e6effd04..f6c27f9b 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -345,6 +345,7 @@ Rainer Zocholl <vdrcontrib@zocki.toppoint.de>
replaying in time shift mode
for suggesting that VDR should stop if one of the configuration files can't be
read correctly at program startup
+ for reporting a possible race condition in generating the DVB device names
Oleg Assovski <assen@bitcom.msk.ru>
for adding EPG scanning for another 4 days
diff --git a/HISTORY b/HISTORY
index 325a9af5..dd5a45b6 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3169,3 +3169,5 @@ Video Disk Recorder Revision History
- Fixed the spelling of 'canceling' (thanks to Wayne Keer for reporting this one).
- Re-introduced a sleep to cDvbPlayer::Action() to avoid high CPU load in still
picture mode (thanks to Reinhard Nissl for reporting this one).
+- Fixed a possible race condition in generating the DVB device names (thanks to
+ Rainer Zocholl for reporting this one).
diff --git a/dvbdevice.c b/dvbdevice.c
index 8780ac53..0c370c4f 100644
--- a/dvbdevice.c
+++ b/dvbdevice.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: dvbdevice.c 1.105 2004/11/20 11:41:37 kls Exp $
+ * $Id: dvbdevice.c 1.106 2004/11/27 10:24:47 kls Exp $
*/
#include "dvbdevice.h"
@@ -46,16 +46,19 @@ extern "C" {
#define DEV_DVB_AUDIO "audio"
#define DEV_DVB_CA "ca"
-static const char *DvbName(const char *Name, int n)
-{
- static char buffer[PATH_MAX];
- snprintf(buffer, sizeof(buffer), "%s%d/%s%d", DEV_DVB_ADAPTER, n, Name, 0);
- return buffer;
-}
+class cDvbName {
+private:
+ char buffer[PATH_MAX];
+public:
+ cDvbName(const char *Name, int n) {
+ snprintf(buffer, sizeof(buffer), "%s%d/%s%d", DEV_DVB_ADAPTER, n, Name, 0);
+ }
+ const char *operator*() { return buffer; }
+ };
static int DvbOpen(const char *Name, int n, int Mode, bool ReportError = false)
{
- const char *FileName = DvbName(Name, n);
+ const char *FileName = *cDvbName(Name, n);
int fd = open(FileName, Mode);
if (fd < 0 && ReportError)
LOG_ERROR_STR(FileName);
@@ -406,7 +409,7 @@ cDvbDevice::cDvbDevice(int n)
dvb_frontend_info feinfo;
if (ioctl(fd_frontend, FE_GET_INFO, &feinfo) >= 0) {
frontendType = feinfo.type;
- ciHandler = cCiHandler::CreateCiHandler(DvbName(DEV_DVB_CA, n));
+ ciHandler = cCiHandler::CreateCiHandler(*cDvbName(DEV_DVB_CA, n));
dvbTuner = new cDvbTuner(fd_frontend, CardIndex(), frontendType, ciHandler);
}
else
@@ -449,7 +452,7 @@ bool cDvbDevice::Initialize(void)
int i;
for (i = 0; i < MAXDVBDEVICES; i++) {
if (UseDevice(NextCardIndex())) {
- if (Probe(DvbName(DEV_DVB_FRONTEND, i))) {
+ if (Probe(*cDvbName(DEV_DVB_FRONTEND, i))) {
new cDvbDevice(i);
found++;
}
@@ -659,7 +662,7 @@ bool cDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On)
int cDvbDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
{
- const char *FileName = DvbName(DEV_DVB_DEMUX, CardIndex());
+ const char *FileName = *cDvbName(DEV_DVB_DEMUX, CardIndex());
int f = open(FileName, O_RDWR | O_NONBLOCK);
if (f >= 0) {
dmx_sct_filter_params sctFilterParams;