Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Re: vdr[3330]: ERROR: can't record MPEG1! - possible cause
Andreas Schultz wrote:
> Hi all,
[...]
> An untested patch for the problem.is attached.
attachements don't work :-(, so here it is again:
--- ./thread.c.orig Fri Sep 21 12:57:35 2001
+++ ./thread.c Fri Sep 21 13:14:06 2001
@@ -53,32 +53,30 @@
// --- cMutex
----------------------------------------------------------------
-cMutex::cMutex(void)
+cMutex::cMutex( Attribute attr )
{
- lockingPid = 0;
- locked = 0;
- pthread_mutex_init(&mutex, NULL);
+ pthread_mutexattr_t m_attr;
+
+ pthread_mutexattr_init( &m_attr);
+ if ( attr != Normal ) {
+ switch (attr) {
+ case Recursive:
+ pthread_mutexattr_settype( &m_attr, PTHREAD_MUTEX_RECURSIVE );
+ break;
+ default:
+ break;
+ }
+ }
+ pthread_mutex_init(&_mutex, &m_attr);
+ pthread_mutexattr_destroy( &m_attr);
}
+
cMutex::~cMutex()
{
pthread_mutex_destroy(&mutex);
}
-void cMutex::Lock(void)
-{
- if (getpid() != lockingPid || !locked)
- pthread_mutex_lock(&mutex);
- lockingPid = getpid();
- locked++;
-}
-
-void cMutex::Unlock(void)
-{
- if (!--locked)
- pthread_mutex_unlock(&mutex);
-}
-
// --- cThread
---------------------------------------------------------------
// The signal handler is necessary to be able to use SIGIO to wake up any
@@ -96,8 +94,7 @@
signalHandlerInstalled = true;
}
running = false;
- parentPid = threadPid = lockingPid = 0;
- locked = 0;
+ parentPid = threadPid = 0;
}
cThread::~cThread()
@@ -158,20 +155,13 @@
bool cThread::Lock(void)
{
- if (!lockingPid || lockingPid != getpid()) {
- Mutex.Lock();
- lockingPid = getpid();
- }
- locked++;
+ Mutex.Lock();
return true;
}
void cThread::Unlock(void)
{
- if (!--locked) {
- lockingPid = 0;
- Mutex.Unlock();
- }
+ Mutex.Unlock();
}
void cThread::WakeUp(void)
--- ./thread.h.orig Fri Sep 21 12:57:58 2001
+++ ./thread.h Fri Sep 21 13:16:12 2001
@@ -32,13 +32,19 @@
friend class cCondVar;
private:
pthread_mutex_t mutex;
- pid_t lockingPid;
- int locked;
public:
- cMutex(void);
+ enum Attribute { Normal, Recursive };
+
+ cMutex(Attribute attr = Recursive);
~cMutex();
- void Lock(void);
- void Unlock(void);
+ void Lock(void)
+ {
+
pthread_mutex_lock( &mutex );
+ }
+ void Unlock(void)
+ {
+
pthread_mutex_unlock( &mutex );
+ }
};
class cThread {
@@ -46,8 +52,7 @@
private:
pthread_t thread;
cMutex Mutex;
- pid_t parentPid, threadPid, lockingPid;
- int locked;
+ pid_t parentPid, threadPid;
bool running;
static time_t lastPanic;
static int panicLevel;
Home |
Main Index |
Thread Index