[mythtv-commits] Ticket #1153: Ringbuffer Race condition
MythTV
mythtv at cvs.mythtv.org
Thu Jan 11 17:48:20 UTC 2007
#1153: Ringbuffer Race condition
-----------------------------+----------------------------------------------
Reporter: ben at vanilla.net | Owner: danielk
Type: defect | Status: new
Priority: minor | Milestone: 0.21
Component: mythtv | Version: head
Severity: medium | Resolution:
-----------------------------+----------------------------------------------
Comment (by david at hardeman.nu):
I have managed to get the backtrace, but it is not very interesting,
SwitchLiveTVRingBuffer is simply executed twice from the TVRec::RunTV
thread.
However, I think I've managed to find the race condition.
At the end of a program, TVRec::RunTV calls SwitchLiveTVRingBuffer with
arguments discont 0, set_rec 1. discont = 0 means that
recorder->CheckForRingBufferSwitch() will not be called in
SwitchLiveTVRingBuffer. TVRec::RunTV then continues and reaches the end of
the loop where it sleeps for 1000ms before the TVRec::RunTV loop is
executed again.
If everything goes well, TVRec::RecorderThread should (during the time
that the TVRec::RunTV thread is sleeping) call RingBufferChanged. In the
example of DVB, the call chain is as follows:
TVRec::TuningNewRecorder -> pthread_create(&recorder_thread, NULL,
TVRec::RecorderThread, recorder); -> TVRec::RecorderThread ->
DVBRecorder::StartRecording -> DVBRecorder::ProcessDataTS ->
DVBRecorder::ProcessTSPacket -> DVBRecorder::ProcessTSPacket2 ->
DTVRecorder::FindMPEG2Keyframes -> DTVRecorder::HandleKeyframe ->
RecorderBase::CheckForRingBufferSwitch -> TVRec::RingBufferChanged
So RingBufferChanged will only be called while the TVRec::RunTV thread is
sleeping if a keyframe is found during that period. Since
RingBufferChanged updates curRecording, TVRec::RunTV will run the same
test with the same curRecording as last time the next time the loop is
executed and re-run SwitchLiveTVRingBuffer if RingBufferChanged hasn't
been executed (i.e. if no keyframe was found).
I'm not sure what the best way to fix this would be....danielk?
--
Ticket URL: <http://svn.mythtv.org/trac/ticket/1153#comment:40>
MythTV <http://www.mythtv.org/>
MythTV
More information about the mythtv-commits
mailing list