From c01259dbb5cf56490de58d6021c9c2fd135d7c66 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Tue, 3 Jan 2006 10:20:41 +0100 Subject: [PATCH] Fixed setting the main thread id if VDR is running as a daemon --- HISTORY | 3 ++- thread.c | 12 ++++++++++-- thread.h | 3 ++- vdr.c | 5 ++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/HISTORY b/HISTORY index 784ce6ec..841950a6 100644 --- a/HISTORY +++ b/HISTORY @@ -3963,7 +3963,7 @@ Video Disk Recorder Revision History commands may now be executed at any time, and the message will be displayed (no more "pending message"). -2006-01-01: Version 1.3.38 +2006-01-03: Version 1.3.38 - Fixed handling second audio and Dolby Digital PIDs for encrypted channels (was broken in version 1.3.37). @@ -4065,3 +4065,4 @@ Video Disk Recorder Revision History - The Makefile now reports a summary of failed plugins (thanks to Udo Richter). - The cTimer constructor can now take an optional cChannel (suggested by Patrick Fischer). +- Fixed setting the main thread id if VDR is running as a daemon. diff --git a/thread.c b/thread.c index 3710817d..af9834ca 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.48 2006/01/01 14:50:44 kls Exp $ + * $Id: thread.c 1.49 2006/01/03 10:15:54 kls Exp $ */ #include "thread.h" @@ -198,7 +198,7 @@ void cMutex::Unlock(void) // --- cThread --------------------------------------------------------------- -tThreadId cThread::mainThreadId = cThread::ThreadId(); +tThreadId cThread::mainThreadId = 0; bool cThread::emergencyExitRequested = false; cThread::cThread(const char *Description) @@ -320,6 +320,14 @@ tThreadId cThread::ThreadId(void) return gettid(); } +void cThread::SetMainThreadId(void) +{ + if (mainThreadId == 0) + mainThreadId = ThreadId(); + else + esyslog("ERROR: attempt to set main thread id to %d while it already is %d", ThreadId(), mainThreadId); +} + // --- cMutexLock ------------------------------------------------------------ cMutexLock::cMutexLock(cMutex *Mutex) diff --git a/thread.h b/thread.h index e3bdccff..e9ccdb31 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.33 2005/12/11 12:04:56 kls Exp $ + * $Id: thread.h 1.34 2006/01/03 10:10:32 kls Exp $ */ #ifndef __THREAD_H @@ -117,6 +117,7 @@ public: static bool EmergencyExit(bool Request = false); static tThreadId ThreadId(void); static tThreadId IsMainThread(void) { return ThreadId() == mainThreadId; } + static void SetMainThreadId(void); }; // cMutexLock can be used to easily set a lock on mutex and make absolutely diff --git a/vdr.c b/vdr.c index cb4ca566..c5c3c180 100644 --- a/vdr.c +++ b/vdr.c @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/vdr * - * $Id: vdr.c 1.224 2005/12/31 13:30:11 kls Exp $ + * $Id: vdr.c 1.225 2006/01/03 10:20:41 kls Exp $ */ #include @@ -473,6 +473,9 @@ int main(int argc, char *argv[]) isyslog("VDR version %s started", VDRVERSION); if (StartedAsRoot) isyslog("switched to user '%s'", VdrUser); + if (DaemonMode) + dsyslog("running as daemon (tid=%d)", cThread::ThreadId()); + cThread::SetMainThreadId(); // Main program loop variables - need to be here to have them initialized before any EXIT():