[mythtv-commits] mythtv commit: r7382 by danielk

mythtv at cvs.mythtv.org mythtv at cvs.mythtv.org
Mon Oct 3 16:54:03 UTC 2005

      Author: danielk
        Date: 2005-10-03 16:54:03 +0000 (Mon, 03 Oct 2005)
New Revision: 7382
   Changeset: http://cvs.mythtv.org/trac/changeset/7382




This should fix the "deadlock" that people have been getting
when exiting and re-entering LiveTV quickly.

This isn't a true deadlock, but rather more like a 'long lock'.

Because the stateChangeLock is a recursive mutex and QWaitCondition
only provides an atomic sleep for non-recursive mutexes we unlock
stateChangeLock before entering the wait in WaitForEventThreadSleep().
This means that if there is a context switch between those two
statements we can end up waiting 30 seconds for a wakeAll() on the
eventThreadSleep wait condition. If this happens in SpawnLiveTV()
and we exit LiveTV before those 30 seconds are up and try to start
LiveTV it won't work (though you could wait 30 seconds and try

Anyway, this commit does three things to address this problem.

First,  we yield before wakeAll in the event loop, this should make
        this much more unlikely.
Second, we send another wakeAll to the event thread after waiting 100 ms
        for a trigger and reaquiring the stateChangeLock.
Third,  after each wait we check if we are sending wakeAll's to
        the event thread, we check if all the events have been
        processed. If so there in no reason to sleep again.

This should reduce the chance of this happending, and also make
sure the delay is 100 ms rather than 30 seconds if it does.

More information about the mythtv-commits mailing list