Skip to content

Commit

Permalink
Mostly revert 788bc51. It's not needed and created a new bug.
Browse files Browse the repository at this point in the history
That change was intended to fix a deadlock.  In reality, it only
worked around the deadlock and added a race condition that could cause
delayed handling of reschedule requests.  It was a series of later
changes that actually fixed the deadlocks, so this fix can be fixed by
reverting it.
  • Loading branch information
gigem committed Jun 4, 2013
1 parent b578a5e commit aafa07e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
9 changes: 3 additions & 6 deletions mythtv/programs/mythbackend/scheduler.cpp
Expand Up @@ -59,7 +59,6 @@ Scheduler::Scheduler(bool runthread, QMap<int, EncoderLink *> *tvList,
recordTable(tmptable),
priorityTable("powerpriority"),
schedLock(),
m_queueLock(),
reclist_changed(false),
specsched(master_sched),
schedulingEnabled(true),
Expand Down Expand Up @@ -1644,7 +1643,7 @@ void Scheduler::GetAllScheduled(QStringList &strList)

void Scheduler::Reschedule(const QStringList &request)
{
QMutexLocker locker(&m_queueLock);
QMutexLocker locker(&schedLock);
reschedQueue.enqueue(request);
reschedWait.wakeOne();
}
Expand Down Expand Up @@ -1789,11 +1788,11 @@ void Scheduler::run(void)
// wait for slaves to connect
sleep(3);

QMutexLocker lockit(&schedLock);

ClearRequestQueue();
EnqueueMatch(0, 0, 0, QDateTime(), "SchedulerInit");

QMutexLocker lockit(&schedLock);

int prerollseconds = 0;
int wakeThreshold = 300;
int idleTimeoutSecs = 0;
Expand Down Expand Up @@ -2122,9 +2121,7 @@ bool Scheduler::HandleReschedule(void)

while (HaveQueuedRequests())
{
m_queueLock.lock();
QStringList request = reschedQueue.dequeue();
m_queueLock.unlock();
QStringList tokens;
if (request.size() >= 1)
tokens = request[0].split(' ', QString::SkipEmptyParts);
Expand Down
20 changes: 7 additions & 13 deletions mythtv/programs/mythbackend/scheduler.h
Expand Up @@ -185,27 +185,21 @@ class Scheduler : public MThread, public MythScheduler

void EnqueueMatch(uint recordid, uint sourceid, uint mplexid,
const QDateTime maxstarttime, const QString &why)
{ QMutexLocker locker(&m_queueLock);
reschedQueue.enqueue(ScheduledRecording::BuildMatchRequest(recordid,
sourceid, mplexid, maxstarttime, why)); };
{ reschedQueue.enqueue(ScheduledRecording::BuildMatchRequest(recordid,
sourceid, mplexid, maxstarttime, why)); };
void EnqueueCheck(const RecordingInfo &recinfo, const QString &why)
{ QMutexLocker locker(&m_queueLock);
reschedQueue.enqueue(ScheduledRecording::BuildCheckRequest(recinfo,
why)); };
{ reschedQueue.enqueue(ScheduledRecording::BuildCheckRequest(recinfo,
why)); };
void EnqueuePlace(const QString &why)
{ QMutexLocker locker(&m_queueLock);
reschedQueue.enqueue(ScheduledRecording::BuildPlaceRequest(why)); };
{ reschedQueue.enqueue(ScheduledRecording::BuildPlaceRequest(why)); };

bool HaveQueuedRequests(void)
{ QMutexLocker locker(&m_queueLock); return !reschedQueue.empty(); };
{ return !reschedQueue.empty(); };
void ClearRequestQueue(void)
{ QMutexLocker locker(&m_queueLock); reschedQueue.clear(); };


{ reschedQueue.clear(); };

MythDeque<QStringList> reschedQueue;
mutable QMutex schedLock;
mutable QMutex m_queueLock;
QMutex recordmatchLock;
QWaitCondition reschedWait;
RecList reclist;
Expand Down

0 comments on commit aafa07e

Please sign in to comment.