From 8fbebb00f7dffe1d2c664d9c005691f59d25e664 Mon Sep 17 00:00:00 2001
From: Bradley Baetz <bbaetz@gmail.com>
Date: Sun, 4 Dec 2016 15:08:47 +1100
Subject: [PATCH] Fix deadlock in libcec initialization.
Configuring the TV at startup is done from the main thread. However, when the
TV state changes as a result of this, libCEC sends a message to the callback
handler on its own thread, which tries to get the UI lock to reset the
screensaver state. This results in a deadlock because the main thread already
has the UI lock during startup time.
Instead, run the initial setup activity at the start of the CEC handler thread.
This was missed in the patch applied for #11986.
Fixes #12754.
---
mythtv/libs/libmythui/cecadapter.cpp | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/mythtv/libs/libmythui/cecadapter.cpp b/mythtv/libs/libmythui/cecadapter.cpp
index 10451a0..ba63c49 100644
a
|
b
|
class CECAdapterPriv |
214 | 214 | |
215 | 215 | LOG(VB_GENERAL, LOG_INFO, LOC + "Opened CEC device."); |
216 | 216 | |
217 | | // all good to go |
218 | | valid = true; |
219 | | |
220 | 217 | // turn on tv (if configured) |
221 | 218 | powerOnTV = powerOnTVOnStart; |
222 | 219 | |
223 | 220 | // switch input (if configured) |
224 | 221 | switchInput = true; |
225 | 222 | |
226 | | HandleActions(); |
| 223 | // all good to go |
| 224 | valid = true; |
227 | 225 | |
228 | 226 | return true; |
229 | 227 | } |
… |
… |
CECAdapter::CECAdapter() : MThread("CECAdapter"), m_priv(new CECAdapterPriv) |
1148 | 1146 | void CECAdapter::run() |
1149 | 1147 | { |
1150 | 1148 | RunProlog(); |
| 1149 | // Handle any actions at startup |
| 1150 | // This is done outside the lock to handle initial setup - |
| 1151 | // we know that nothing else can be calling us this early. |
| 1152 | m_priv->HandleActions(); |
| 1153 | |
1151 | 1154 | while (IsValid()) { |
1152 | 1155 | // Note that a lock is used because the QWaitCondition needs it |
1153 | 1156 | // None of the other HandleActions callers need the lock because |