Fixed a possible race condition in cDevice::Action() and cTSBuffer::Action()

This commit is contained in:
Klaus Schmidinger 2005-01-16 14:50:33 +01:00
parent c522225344
commit 8c0981583f
3 changed files with 10 additions and 6 deletions

View File

@ -189,6 +189,7 @@ Stefan Huelswitt <huels@iname.com>
skin in case a shorter title is set after a longer one skin in case a shorter title is set after a longer one
for fixing handling of pmAudioOnlyBlack for fixing handling of pmAudioOnlyBlack
for pointing out possible race conditions in handling childTid in cThread for pointing out possible race conditions in handling childTid in cThread
for fixing a possible race condition in cDevice::Action() and cTSBuffer::Action()
Ulrich Röder <roeder@efr-net.de> Ulrich Röder <roeder@efr-net.de>
for pointing out that there are channels that have a symbol rate higher than for pointing out that there are channels that have a symbol rate higher than

View File

@ -3318,3 +3318,5 @@ Video Disk Recorder Revision History
cRecorder::cRecorder() cRecorder::cRecorder()
cReceiver::cReceiver() cReceiver::cReceiver()
cRemux::cRemux() cRemux::cRemux()
- Fixed a possible race condition in cDevice::Action() and cTSBuffer::Action()
(thanks to Stefan Huelswitt).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: device.c 1.74 2005/01/16 14:05:37 kls Exp $ * $Id: device.c 1.75 2005/01/16 14:48:52 kls Exp $
*/ */
#include "device.h" #include "device.h"
@ -991,8 +991,7 @@ bool cDevice::Receiving(bool CheckAny) const
void cDevice::Action(void) void cDevice::Action(void)
{ {
active = true; if (active && OpenDvr()) {
if (OpenDvr()) {
for (; active;) { for (; active;) {
// Read data from the DVR device: // Read data from the DVR device:
uchar *b = NULL; uchar *b = NULL;
@ -1054,7 +1053,10 @@ bool cDevice::AttachReceiver(cReceiver *Receiver)
Receiver->device = this; Receiver->device = this;
receiver[i] = Receiver; receiver[i] = Receiver;
Unlock(); Unlock();
Start(); if (!active) {
active = true;
Start();
}
return true; return true;
} }
} }
@ -1094,10 +1096,10 @@ cTSBuffer::cTSBuffer(int File, int Size, int CardIndex)
SetDescription("TS buffer on device %d", CardIndex); SetDescription("TS buffer on device %d", CardIndex);
f = File; f = File;
cardIndex = CardIndex; cardIndex = CardIndex;
active = false;
delivered = false; delivered = false;
ringBuffer = new cRingBufferLinear(Size, TS_SIZE, true, "TS"); ringBuffer = new cRingBufferLinear(Size, TS_SIZE, true, "TS");
ringBuffer->SetTimeouts(100, 100); ringBuffer->SetTimeouts(100, 100);
active = true;
Start(); Start();
} }
@ -1113,7 +1115,6 @@ void cTSBuffer::Action(void)
if (ringBuffer) { if (ringBuffer) {
bool firstRead = true; bool firstRead = true;
cPoller Poller(f); cPoller Poller(f);
active = true;
for (; active;) { for (; active;) {
if (firstRead || Poller.Poll(100)) { if (firstRead || Poller.Poll(100)) {
firstRead = false; firstRead = false;