Skip to content

Commit

Permalink
Fixes #10970. Fix StreamHandler restart race.
Browse files Browse the repository at this point in the history
We wait for _running to be set to false, but we need the thread to be
in the finish state or QThread::start() will exit silently without
starting the thread. Since we're calling QThread::wait() we don't
really need the while (_running) loop at all in either Start() or
Stop(), so I've removed it. This race probably dates back to the
pthread->QThread porting.
  • Loading branch information
daniel-kristjansson committed Aug 3, 2012
1 parent 9f0be65 commit 7d01e69
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions mythtv/libs/libmythtv/streamhandler.cpp
Expand Up @@ -150,9 +150,11 @@ void StreamHandler::Start(void)
if ((_using_section_reader && !_allow_section_reader) ||
(_needs_buffering && !_using_buffering))
{
LOG(VB_RECORD, LOG_INFO, LOC + "Restarting StreamHandler");
SetRunningDesired(false);
while (!_running_desired && _running)
_running_state_changed.wait(&_start_stop_lock, 100);
locker.unlock();
wait();
locker.relock();
}
}

Expand All @@ -170,19 +172,14 @@ void StreamHandler::Start(void)

if (_error)
{
LOG(VB_GENERAL, LOG_WARNING, LOC + "Start failed");
LOG(VB_GENERAL, LOG_ERR, LOC + "Start failed");
SetRunningDesired(false);
}
}

void StreamHandler::Stop(void)
{
QMutexLocker locker(&_start_stop_lock);

SetRunningDesired(false);
while (_running)
_running_state_changed.wait(&_start_stop_lock, 100);

wait();
}

Expand Down

0 comments on commit 7d01e69

Please sign in to comment.