summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2004-11-26 14:05:36 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2004-11-26 14:05:36 +0100
commiteb8405695b93c76ae7bf9b17df8767907fe5d4d8 (patch)
tree3fe1886c1c77992dd1ef54fefb7be69ee99eea82
parent4146ac1928fc5a60456bb43dccce352b984e57a3 (diff)
downloadvdr-eb8405695b93c76ae7bf9b17df8767907fe5d4d8.tar.gz
vdr-eb8405695b93c76ae7bf9b17df8767907fe5d4d8.tar.bz2
Some more changes to the 'childTid' handling in cThread
-rw-r--r--HISTORY4
-rw-r--r--thread.c13
-rw-r--r--thread.h3
3 files changed, 13 insertions, 7 deletions
diff --git a/HISTORY b/HISTORY
index 27a905ba..92933c41 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3160,7 +3160,9 @@ Video Disk Recorder Revision History
right day of week for timers in the future.
- Some improvements to cPoller (thanks to Marco Schlüßler).
-2004-11-22: Version 1.3.18
+2004-11-26: Version 1.3.18
- Removed an unused variable from cTimer::GetWDayFromMDay() (thanks to Wayne Keer
for reporting this one).
+- Some more changes to the 'childTid' handling in cThread (based on suggestions by
+ Stefan Huelswitt).
diff --git a/thread.c b/thread.c
index 7045e5ad..0bb7110e 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.37 2004/11/20 16:21:14 kls Exp $
+ * $Id: thread.c 1.38 2004/11/26 13:50:37 kls Exp $
*/
#include "thread.h"
@@ -221,19 +221,22 @@ void cThread::SetDescription(const char *Description, ...)
void *cThread::StartThread(cThread *Thread)
{
+ Thread->childTidMutex.Lock();
Thread->childTid = pthread_self();
+ Thread->childTidMutex.Unlock();
if (Thread->description)
dsyslog("%s thread started (pid=%d, tid=%ld)", Thread->description, getpid(), Thread->childTid);
Thread->Action();
if (Thread->description)
dsyslog("%s thread ended (pid=%d, tid=%ld)", Thread->description, getpid(), Thread->childTid);
+ Thread->childTidMutex.Lock();
Thread->childTid = 0;
+ Thread->childTidMutex.Unlock();
return NULL;
}
bool cThread::Start(void)
{
- Lock();
if (!childTid) {
parentTid = pthread_self();
pthread_t Tid;
@@ -241,7 +244,6 @@ bool cThread::Start(void)
pthread_detach(Tid); // auto-reap
pthread_setschedparam(Tid, SCHED_RR, 0);
}
- Unlock();
return true; //XXX return value of pthread_create()???
}
@@ -257,6 +259,7 @@ bool cThread::Active(void)
// As in kill(), if sig is zero, error checking is
// performed but no signal is actually sent.
//
+ cMutexLock MutexLock(&childTidMutex);
int err;
if ((err = pthread_kill(childTid, 0)) != 0) {
if (err != ESRCH)
@@ -280,12 +283,12 @@ void cThread::Cancel(int WaitSeconds)
}
esyslog("ERROR: thread %ld won't end (waited %d seconds) - cancelling it...", childTid, WaitSeconds);
}
- Lock();
+ childTidMutex.Lock();
if (childTid) {
pthread_cancel(childTid);
childTid = 0;
}
- Unlock();
+ childTidMutex.Unlock();
}
}
diff --git a/thread.h b/thread.h
index 2cc623bf..c3d8d06a 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.24 2004/10/24 11:00:32 kls Exp $
+ * $Id: thread.h 1.25 2004/11/26 13:33:26 kls Exp $
*/
#ifndef __THREAD_H
@@ -74,6 +74,7 @@ class cThread {
friend class cThreadLock;
private:
pthread_t parentTid, childTid;
+ cMutex childTidMutex;
cMutex mutex;
char *description;
static bool emergencyExitRequested;