[mythtv] [PATCH] Fix for DVB freezes

Dan Sheridan djs52 at postman.org.uk
Mon Mar 29 08:40:55 EST 2004

It's taken me about three weeks of debugging, but here, at last, is a
fix for the freezes that have been plaguing me in MythTV. The problem is
as follows: the quality monitoring thread wakes up every so often and
checks the quality data from the card which it then commits to the
database. When the a recoding finishes, the thread is *cancelled*, which
may happen at any time; with a slow enough database or a fast enough
poll rate for the quality data, there is a good chance that the thread
is cancelled while it holds the database lock. This results in a
deadlock: the state change from RecordingOnly to None cannot complete,
holding up everything else. 

The problem with debugging comes from a bizarre gcc policy where if a
call to the stdlib (eg cerr << "debugging info"...) is running when a
thread is cancelled, the whole program terminates with a "FATAL:
exception not rethrown" error, which is not documented anywhere! The
patch below therefore replaces the pthread_cancel with a semaphore in
the style of the rest of the code; the catch is that if the monitoring
interval for the quality thread is too large it may take a while to
exit. (In fact, if the card is reopened before the thread has stopped
the semaphore will be reset and two instances of the thread will
continue to run. Any suggestions?)


Dan Sheridan -- Research Student -- LFCS, Division of Informatics
University of Edinburgh, King's Buildings, Mayfield Road EH9 3JZ
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeze.patch
Type: text/x-patch
Size: 1849 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20040329/fb45cb96/freeze.bin

More information about the mythtv-dev mailing list