Permalink
Browse files

Revert "Protect the reschedule queue with a seperate lock to fix a ba…

…ckend deadlock."

This reverts commit 5eb9779.

While this seems to work well in master, it appears to make the
situation worse in 0.25 and I really don't have the time to figure out
why. Anyone experiencing the pre-existing deadlock will need to
upgrade to 0.26 when it's released. Refs #10771
  • Loading branch information...
1 parent 67522d8 commit 48ac7cfb51e82c3ddbaab489810b560fb8271531 @stuartm stuartm committed Jul 4, 2012
Showing with 8 additions and 41 deletions.
  1. +8 −35 mythtv/programs/mythbackend/scheduler.cpp
  2. +0 −6 mythtv/programs/mythbackend/scheduler.h
@@ -57,7 +57,6 @@ Scheduler::Scheduler(bool runthread, QMap<int, EncoderLink *> *tvList,
recordTable(tmptable),
priorityTable("powerpriority"),
schedLock(),
- m_queueLock(),
reclist_changed(false),
specsched(master_sched),
schedMoveHigher(false),
@@ -594,9 +593,7 @@ void Scheduler::UpdateRecStatus(RecordingInfo *pginfo)
p->AddHistory(false);
if (resched)
{
- m_queueLock.lock();
reschedQueue.enqueue(0);
- m_queueLock.unlock();
reschedWait.wakeOne();
}
else
@@ -646,9 +643,7 @@ void Scheduler::UpdateRecStatus(uint cardid, uint chanid,
p->AddHistory(false);
if (resched)
{
- m_queueLock.lock();
reschedQueue.enqueue(0);
- m_queueLock.unlock();
reschedWait.wakeOne();
}
else
@@ -1620,7 +1615,7 @@ void Scheduler::GetAllScheduled(QStringList &strList)
void Scheduler::Reschedule(int recordid)
{
- QMutexLocker locker(&m_queueLock);
+ QMutexLocker locker(&schedLock);
if (recordid == -1)
reschedQueue.clear();
@@ -1666,9 +1661,7 @@ void Scheduler::AddRecording(const RecordingInfo &pi)
new_pi->GetRecordingRule();
// Trigger reschedule..
- m_queueLock.lock();
reschedQueue.enqueue(pi.GetRecordingRuleID());
- m_queueLock.unlock();
reschedWait.wakeOne();
}
@@ -1772,13 +1765,11 @@ void Scheduler::run(void)
// wait for slaves to connect
sleep(3);
- ClearRequestQueue();
- m_queueLock.lock();
+ QMutexLocker lockit(&schedLock);
+
+ reschedQueue.clear();
reschedQueue.enqueue(-1);
- m_queueLock.unlock();
- QMutexLocker lockit(&schedLock);
-
int prerollseconds = 0;
int wakeThreshold = 300;
int idleTimeoutSecs = 0;
@@ -1816,7 +1807,7 @@ void Scheduler::run(void)
}
else
{
- if (!HaveQueuedRequests())
+ if (reschedQueue.empty())
{
int sched_sleep = (secs_to_next - schedRunTime - 1) * 1000;
sched_sleep = min(sched_sleep, maxSleep);
@@ -1831,7 +1822,7 @@ void Scheduler::run(void)
}
QTime t; t.start();
- if (HaveQueuedRequests() && HandleReschedule())
+ if (!reschedQueue.empty() && HandleReschedule())
{
statuschanged = true;
startIter = reclist.begin();
@@ -2012,19 +2003,17 @@ bool Scheduler::HandleReschedule(void)
QString msg;
bool deleteFuture = false;
- while (HaveQueuedRequests())
+ while (!reschedQueue.empty())
{
- m_queueLock.lock();
int recordid = reschedQueue.dequeue();
- m_queueLock.unlock();
LOG(VB_GENERAL, LOG_INFO, QString("Reschedule requested for id %1.")
.arg(recordid));
if (recordid != 0)
{
if (recordid == -1)
- ClearRequestQueue();
+ reschedQueue.clear();
deleteFuture = true;
schedLock.unlock();
@@ -2067,9 +2056,7 @@ bool Scheduler::HandleReschedule(void)
else
{
LOG(VB_GENERAL, LOG_INFO, "Reschedule interrupted, will retry");
- m_queueLock.lock();
reschedQueue.enqueue(0);
- m_queueLock.lock();
return false;
}
@@ -2229,11 +2216,7 @@ void Scheduler::HandleWakeSlave(RecordingInfo &ri, int prerollseconds)
.arg(nexttv->GetHostName()).arg(ri.GetTitle()));
if (!WakeUpSlave(nexttv->GetHostName()))
- {
- m_queueLock.lock();
reschedQueue.enqueue(0);
- m_queueLock.unlock();
- }
}
else if ((nexttv->IsWaking()) &&
((secsleft - prerollseconds) < 210) &&
@@ -2246,11 +2229,7 @@ void Scheduler::HandleWakeSlave(RecordingInfo &ri, int prerollseconds)
.arg(nexttv->GetHostName()));
if (!WakeUpSlave(nexttv->GetHostName(), false))
- {
- m_queueLock.lock();
reschedQueue.enqueue(0);
- m_queueLock.unlock();
- }
}
else if ((nexttv->IsWaking()) &&
((secsleft - prerollseconds) < 150) &&
@@ -2270,9 +2249,7 @@ void Scheduler::HandleWakeSlave(RecordingInfo &ri, int prerollseconds)
(*it)->SetSleepStatus(sStatus_Undefined);
}
- m_queueLock.lock();
reschedQueue.enqueue(0);
- m_queueLock.unlock();
}
}
@@ -2310,9 +2287,7 @@ bool Scheduler::HandleRecording(
livetvTime = (livetvTime < nextrectime) ?
nextrectime : livetvTime;
- m_queueLock.lock();
reschedQueue.enqueue(0);
- m_queueLock.unlock();
}
}
@@ -2395,9 +2370,7 @@ bool Scheduler::HandleRecording(
enc->SetSleepStatus(sStatus_Undefined);
}
- m_queueLock.lock();
reschedQueue.enqueue(0);
- m_queueLock.unlock();
}
return false;
@@ -165,16 +165,10 @@ class Scheduler : public MThread, public MythScheduler
bool &blockShutdown, QDateTime &idleSince, int prerollseconds,
int idleTimeoutSecs, int idleWaitForRecordingTime,
bool &statuschanged);
-
- bool HaveQueuedRequests(void)
- { QMutexLocker locker(&m_queueLock); return !reschedQueue.empty(); };
- void ClearRequestQueue(void)
- { QMutexLocker locker(&m_queueLock); reschedQueue.clear(); };
MythDeque<int> reschedQueue;
mutable QMutex schedLock;
- mutable QMutex m_queueLock;
QMutex recordmatchLock;
QWaitCondition reschedWait;
RecList reclist;

0 comments on commit 48ac7cf

Please sign in to comment.