summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY4
-rw-r--r--device.c4
-rw-r--r--device.h3
3 files changed, 8 insertions, 3 deletions
diff --git a/HISTORY b/HISTORY
index 9fd32246..48e36e25 100644
--- a/HISTORY
+++ b/HISTORY
@@ -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.
diff --git a/device.c b/device.c
index 7c8d97cd..2df50dab 100644
--- a/device.c
+++ b/device.c
@@ -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);
diff --git a/device.h b/device.h
index d4bd9f23..2c147986 100644
--- a/device.h
+++ b/device.h
@@ -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: