Ludwig Nussel wrote: > vdr-1.2.6-threadcancelsegv.diff - fix a segfault Update: Added a check for childTid != 0 before calling pthread_cancel() otherwise some plugins like bitstreamout cause vdr to segfault at exit. I also removed the usleep after StartThread. So far doesn't cause problems here. cu Ludwig -- (o_ Ludwig.Nussel@gmx.de //\ PGP Key ID: FF8135CE V_/_ ICQ: 52166811
Index: vdr-1.2.6/thread.c =================================================================== --- vdr-1.2.6.orig/thread.c 2004-06-15 00:49:11.000000000 +0200 +++ vdr-1.2.6/thread.c 2004-06-20 13:23:49.608101219 +0200 @@ -189,7 +189,6 @@ pthread_create(&childTid, NULL, (void *(*) (void *))&StartThread, (void *)this); pthread_detach(childTid); // auto-reap pthread_setschedparam(childTid, SCHED_RR, 0); - usleep(10000); // otherwise calling Active() immediately after Start() causes a "pure virtual method called" error } return true; //XXX return value of pthread_create()??? } @@ -220,6 +219,7 @@ void cThread::Cancel(int WaitSeconds) { + if(!running) return; running = false; if (WaitSeconds > 0) { for (time_t t0 = time(NULL) + WaitSeconds; time(NULL) < t0; ) { @@ -229,7 +229,11 @@ } esyslog("ERROR: thread %ld won't end (waited %d seconds) - cancelling it...", childTid, WaitSeconds); } - pthread_cancel(childTid); + if(childTid) + { + pthread_cancel(childTid); + childTid = 0; + } } void cThread::WakeUp(void)
Attachment:
pgp00020.pgp
Description: PGP signature