diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2004-12-24 15:37:11 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2004-12-24 15:37:11 +0100 |
commit | f97b1069c6bdf519fd32280b35ed66abe6c02bde (patch) | |
tree | cc2d570d206287b26bb46631f298f70ca42b46d5 | |
parent | c49253824a46a45dac86d2a0404b9d5c6e1a92a4 (diff) | |
download | vdr-f97b1069c6bdf519fd32280b35ed66abe6c02bde.tar.gz vdr-f97b1069c6bdf519fd32280b35ed66abe6c02bde.tar.bz2 |
Added cDevice::mutexReceiver to avoid a race condition when attaching/detaching receivers from different threads
-rw-r--r-- | HISTORY | 4 | ||||
-rw-r--r-- | device.c | 4 | ||||
-rw-r--r-- | device.h | 3 |
3 files changed, 8 insertions, 3 deletions
@@ -3160,7 +3160,7 @@ Video Disk Recorder Revision History right day of week for timers in the future. - Some improvements to cPoller (thanks to Marco Schlüßler). -2004-12-19: Version 1.3.18 +2004-12-24: Version 1.3.18 - Removed an unused variable from cTimer::GetWDayFromMDay() (thanks to Wayne Keer for reporting this one). @@ -3224,3 +3224,5 @@ Video Disk Recorder Revision History - Removed delay_ms(), using cCondWait::SleepMs() instead. - Replaced time_ms() with a threadsafe and non-overflowing cTimeMs (thanks to Rainer Zocholl for pointing out this problem). +- Added cDevice::mutexReceiver to avoid a race condition when attaching/detaching + receivers from different threads. @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.c 1.63 2004/12/17 13:51:44 kls Exp $ + * $Id: device.c 1.64 2004/12/24 15:37:11 kls Exp $ */ #include "device.h" @@ -990,6 +990,7 @@ bool cDevice::AttachReceiver(cReceiver *Receiver) esyslog("ERROR: device %d has no lock, can't attach receiver!", CardIndex() + 1); return false; } + cMutexLock MutexLock(&mutexReceiver); for (int i = 0; i < MAXRECEIVERS; i++) { if (!receiver[i]) { for (int n = 0; n < MAXRECEIVEPIDS; n++) { @@ -1017,6 +1018,7 @@ void cDevice::Detach(cReceiver *Receiver) if (!Receiver || Receiver->device != this) return; bool receiversLeft = false; + cMutexLock MutexLock(&mutexReceiver); for (int i = 0; i < MAXRECEIVERS; i++) { if (receiver[i] == Receiver) { Receiver->Activate(false); @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.h 1.47 2004/12/17 13:44:34 kls Exp $ + * $Id: device.h 1.48 2004/12/24 14:57:24 kls Exp $ */ #ifndef __DEVICE_H @@ -448,6 +448,7 @@ public: // Receiver facilities private: + cMutex mutexReceiver; cReceiver *receiver[MAXRECEIVERS]; int CanShift(int Ca, int Priority, int UsedCards = 0) const; protected: |