mirror of
				https://github.com/vdr-projects/vdr.git
				synced 2025-03-01 10:50:46 +00:00 
			
		
		
		
	Using the thread id in the "thread ... won't end" error message
This commit is contained in:
		
							
								
								
									
										10
									
								
								thread.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								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.49 2006/01/03 10:15:54 kls Exp $
 | 
			
		||||
 * $Id: thread.c 1.50 2006/01/04 15:01:22 kls Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "thread.h"
 | 
			
		||||
@@ -205,6 +205,7 @@ cThread::cThread(const char *Description)
 | 
			
		||||
{
 | 
			
		||||
  active = running = false;
 | 
			
		||||
  childTid = 0;
 | 
			
		||||
  childThreadId = 0;
 | 
			
		||||
  description = NULL;
 | 
			
		||||
  SetDescription(Description);
 | 
			
		||||
}
 | 
			
		||||
@@ -235,11 +236,12 @@ void cThread::SetDescription(const char *Description, ...)
 | 
			
		||||
 | 
			
		||||
void *cThread::StartThread(cThread *Thread)
 | 
			
		||||
{
 | 
			
		||||
  Thread->childThreadId = ThreadId();
 | 
			
		||||
  if (Thread->description)
 | 
			
		||||
     dsyslog("%s thread started (pid=%d, tid=%d)", Thread->description, getpid(), ThreadId());
 | 
			
		||||
     dsyslog("%s thread started (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId);
 | 
			
		||||
  Thread->Action();
 | 
			
		||||
  if (Thread->description)
 | 
			
		||||
     dsyslog("%s thread ended (pid=%d, tid=%d)", Thread->description, getpid(), ThreadId());
 | 
			
		||||
     dsyslog("%s thread ended (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId);
 | 
			
		||||
  Thread->running = false;
 | 
			
		||||
  Thread->active = false;
 | 
			
		||||
  return NULL;
 | 
			
		||||
@@ -297,7 +299,7 @@ void cThread::Cancel(int WaitSeconds)
 | 
			
		||||
               return;
 | 
			
		||||
            cCondWait::SleepMs(10);
 | 
			
		||||
            }
 | 
			
		||||
        esyslog("ERROR: thread %ld won't end (waited %d seconds) - canceling it...", childTid, WaitSeconds);
 | 
			
		||||
        esyslog("ERROR: thread %d won't end (waited %d seconds) - canceling it...", childThreadId, WaitSeconds);
 | 
			
		||||
        }
 | 
			
		||||
     pthread_cancel(childTid);
 | 
			
		||||
     childTid = 0;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								thread.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								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.34 2006/01/03 10:10:32 kls Exp $
 | 
			
		||||
 * $Id: thread.h 1.35 2006/01/04 14:58:16 kls Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef __THREAD_H
 | 
			
		||||
@@ -80,6 +80,7 @@ private:
 | 
			
		||||
  bool active;
 | 
			
		||||
  bool running;
 | 
			
		||||
  pthread_t childTid;
 | 
			
		||||
  tThreadId childThreadId;
 | 
			
		||||
  cMutex mutex;
 | 
			
		||||
  char *description;
 | 
			
		||||
  static tThreadId mainThreadId;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user