summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2003-10-18 13:20:01 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2003-10-18 13:20:01 +0200
commite7b6b2fff72cb7221d171b096ea844467af635fe (patch)
tree5ca3163fd5cea2de5f7a5d5c0c212f8c1d68d7d4
parentb658b1fe16152683fecb0f1d3c2a1e65edfb0969 (diff)
downloadvdr-e7b6b2fff72cb7221d171b096ea844467af635fe.tar.gz
vdr-e7b6b2fff72cb7221d171b096ea844467af635fe.tar.bz2
Mutexes are now created with PTHREAD_MUTEX_ERRORCHECK_NP
-rw-r--r--CONTRIBUTORS2
-rw-r--r--HISTORY2
-rw-r--r--thread.c20
-rw-r--r--thread.h3
4 files changed, 12 insertions, 15 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 06f67c86..03bce095 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -178,6 +178,8 @@ Stefan Huelswitt <huels@iname.com>
for fixing a possible access of invalid file handles in cSIProcessor::Action()
for fixing extracting the ES data in cDvbDevice::StillPicture()
for changing thread handling to make it work with NPTL ("Native Posix Thread Library")
+ for creating mutexes with PTHREAD_MUTEX_ERRORCHECK_NP, which made the 'lockingTid'
+ stuff obsolete
Ulrich Röder <roeder@efr-net.de>
for pointing out that there are channels that have a symbol rate higher than
diff --git a/HISTORY b/HISTORY
index 80fd582b..7c98c23f 100644
--- a/HISTORY
+++ b/HISTORY
@@ -2446,3 +2446,5 @@ Video Disk Recorder Revision History
instead of explicit 'dsyslog()' calls inside their Action() function in order
to support logging the thread ids.
- Added "Slovak Link" and "Czech Link" to 'ca.conf' (thanks to Emil Petersky).
+- Mutexes are now created with PTHREAD_MUTEX_ERRORCHECK_NP, which makes the
+ 'lockingTid' stuff obsolete (thanks to Stefan Huelswitt).
diff --git a/thread.c b/thread.c
index 49c01a24..f76e8447 100644
--- a/thread.c
+++ b/thread.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: thread.c 1.27 2003/10/18 12:14:55 kls Exp $
+ * $Id: thread.c 1.28 2003/10/18 13:00:04 kls Exp $
*/
#include "thread.h"
@@ -32,7 +32,7 @@ cCondVar::~cCondVar()
void cCondVar::Wait(cMutex &Mutex)
{
- if (Mutex.locked && pthread_equal(Mutex.lockingTid, pthread_self())) {
+ if (Mutex.locked) {
int locked = Mutex.locked;
Mutex.locked = 0; // have to clear the locked count here, as pthread_cond_wait
// does an implizit unlock of the mutex
@@ -45,7 +45,7 @@ bool cCondVar::TimedWait(cMutex &Mutex, int TimeoutMs)
{
bool r = true; // true = condition signaled false = timeout
- if (Mutex.locked && pthread_equal(Mutex.lockingTid, pthread_self())) {
+ if (Mutex.locked) {
struct timeval now; // unfortunately timedwait needs the absolute time, not the delta :-(
if (gettimeofday(&now, NULL) == 0) { // get current time
now.tv_usec += TimeoutMs * 1000; // add the timeout
@@ -63,7 +63,6 @@ bool cCondVar::TimedWait(cMutex &Mutex, int TimeoutMs)
if (pthread_cond_timedwait(&cond, &Mutex.mutex, &abstime) == ETIMEDOUT)
r = false;
Mutex.locked = locked;
- Mutex.lockingTid = pthread_self();
}
}
return r;
@@ -85,9 +84,9 @@ void cCondVar::Signal(void)
cMutex::cMutex(void)
{
- lockingTid = 0;
locked = 0;
- pthread_mutex_init(&mutex, NULL);
+ pthread_mutexattr_t attr = { PTHREAD_MUTEX_ERRORCHECK_NP };
+ pthread_mutex_init(&mutex, &attr);
}
cMutex::~cMutex()
@@ -97,19 +96,14 @@ cMutex::~cMutex()
void cMutex::Lock(void)
{
- if (!pthread_equal(lockingTid, pthread_self()) || !locked) {
- pthread_mutex_lock(&mutex);
- lockingTid = pthread_self();
- }
+ pthread_mutex_lock(&mutex);
locked++;
}
void cMutex::Unlock(void)
{
- if (!--locked) {
- lockingTid = 0;
+ if (!--locked)
pthread_mutex_unlock(&mutex);
- }
}
// --- cThread ---------------------------------------------------------------
diff --git a/thread.h b/thread.h
index ec4e1395..fc60588c 100644
--- a/thread.h
+++ b/thread.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: thread.h 1.17 2003/10/18 12:13:10 kls Exp $
+ * $Id: thread.h 1.18 2003/10/18 12:56:20 kls Exp $
*/
#ifndef __THREAD_H
@@ -32,7 +32,6 @@ class cMutex {
friend class cCondVar;
private:
pthread_mutex_t mutex;
- pthread_t lockingTid;
int locked;
public:
cMutex(void);