Mailing List Archive

mythtv/master commit: 0434cd982 by Daniel Thor Kristjansson (daniel-kristjansson)
Author: Daniel Thor Kristjansson <dkristjansson@mythtv.org>
Change Date: 2011-05-11T08:42:30-07:00
Push Date: 2011/05/11 08:48:06 -0700
Repository: mythtv
Branch: master
New Revision: 0434cd9826a1cd67034315fc4c0999a048296630
Changeset: https://github.com/MythTV/mythtv/commit/0434cd982

Log:

Various threading cleanups copied from mythtv-rec2 branch.

Gavin Hurlibut undertook a large code cleanup of our threading some
weeks back. But there were a few systematic problems in the handling
of thread startup and shutdown. Except for adding a QThread::wait()
to QThread dtors and bugs relating to detached threads, the major
ones have been identified and fixed in previous commits by Gavin.
This commit collects a number of minor ones that I accumulated
in the mythtv-rec2 branch, as well as fixes for bugs that I
identified while reviewing Gavin's work but that were in fact
pre-existing bugs, and finally it reverts three commits that are
trouble, but a rework hasn't yet been completed.

NOTE: I did not review the SignalMonitor threading changes, the
code in mythtv-rec2 for these is too different.

There are some systematic changes:
Important:
Added QThread::wait(); to all QThread based class destructors
This ensures that if we try to delete a QThread based class
while it's underlying thread is still running we get a deadlock
instead of a stackless segfault. As a deadlock is much easier to debug.
Minor:
Got rid of SetParent() call, instead make this a ctor param.
This just allows us to do the same things in fewer lines of code.
Fixed member variable names beginning with a capital letter.
Explicitly allocated and deallocated all QThread based classes.
We don't always have good control over which thread the parent
classes ctor/dtor is run. This just gives us a little more
flexibility.
Got rid of "#include <pthread.h>" where no pthread stuff was used.

There are some specific changes:
The housekeeper thread now can be stopped more quickly, and without
risking a deadlock. The problems here pre-existed recent threading
changes.
The recorders now use a pauseLock when handling pausing and unpausing
of the recorders. A problem was introduced a while back with the
Qt4 port in the handling of recorder pausing. This just get's
carried along with the Recorder Thread QThread port because of
how I had implemented it there.
Fixed some incorrect locking introduced in the Qt4 port to MHEGContext.
There were a few cases where the start/stop handling wasn't quite
right. Unfortunately this often required some class specific code.

There are some reverts:
Go back to pthread for ddMapLoader.
This used to create a detached thread in one of the two uses,
but after recent changes it instead created an attached thread
which was then leaked. Fixing is non-trivial.
Go back to pthread for two of the three threads in jobqueue
A detached thread problem. There are already two efforts underway
to fix this in different ways.
DarwinFirewireDevice. This just doesn't look right, before or
after the pthread->QThread port. We don't appear to guarantee
that the thread ever finishes. Without a machine to test this
on I think it's safest just to revert. All OSX machines have
a decent pthreads implementation.

Modified:

mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
mythtv/libs/libmythtv/NuppelVideoRecorder.h
mythtv/libs/libmythtv/ThreadedFileWriter.cpp
mythtv/libs/libmythtv/ThreadedFileWriter.h
mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
mythtv/libs/libmythtv/channelscan/channelscan_sm.h
mythtv/libs/libmythtv/darwinfirewiredevice.cpp
mythtv/libs/libmythtv/darwinfirewiredevice.h
mythtv/libs/libmythtv/dvbcam.cpp
mythtv/libs/libmythtv/dvbcam.h
mythtv/libs/libmythtv/dvbrecorder.cpp
mythtv/libs/libmythtv/fifowriter.cpp
mythtv/libs/libmythtv/fifowriter.h
mythtv/libs/libmythtv/firewirerecorder.cpp
mythtv/libs/libmythtv/frequencies.cpp
mythtv/libs/libmythtv/hdhrrecorder.cpp
mythtv/libs/libmythtv/hdhrsignalmonitor.cpp
mythtv/libs/libmythtv/interactivetv.cpp
mythtv/libs/libmythtv/iptvrecorder.cpp
mythtv/libs/libmythtv/iptvrecorder.h
mythtv/libs/libmythtv/jobqueue.cpp
mythtv/libs/libmythtv/jobqueue.h
mythtv/libs/libmythtv/linuxfirewiredevice.cpp
mythtv/libs/libmythtv/linuxfirewiredevice.h
mythtv/libs/libmythtv/mhi.cpp
mythtv/libs/libmythtv/mhi.h
mythtv/libs/libmythtv/mpegrecorder.cpp
mythtv/libs/libmythtv/nuppeldecoder.cpp
mythtv/libs/libmythtv/recorderbase.cpp
mythtv/libs/libmythtv/recorderbase.h
mythtv/libs/libmythtv/tv_play.cpp
mythtv/libs/libmythtv/tv_play.h
mythtv/libs/libmythtv/tv_rec.cpp
mythtv/libs/libmythtv/tv_rec.h
mythtv/libs/libmythui/mythmainwindow.cpp
mythtv/programs/mythbackend/filetransfer.h
mythtv/programs/mythbackend/housekeeper.cpp
mythtv/programs/mythbackend/housekeeper.h
mythtv/programs/mythbackend/main.cpp
mythtv/programs/mythbackend/main_helpers.cpp
mythtv/programs/mythbackend/scheduler.cpp
mythtv/programs/mythbackend/scheduler.h
mythtv/programs/mythfrontend/networkcontrol.cpp
mythtv/programs/mythfrontend/networkcontrol.h

_______________________________________________
mythtv-firehose mailing list
mythtv-firehose@mythtv.org
http://www.mythtv.org/mailman/listinfo/mythtv-firehose