From: Lars Op den Kamp Date: Tue, 4 Oct 2011 18:31:56 +0000 (+0200) Subject: cec: fix segfault on exit X-Git-Tag: upstream/2.2.0~1^2~295 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f7e6ba706d8e9ded6d65139da93309b22fd3d4ed;p=deb_libcec.git cec: fix segfault on exit --- diff --git a/src/lib/AdapterCommunication.cpp b/src/lib/AdapterCommunication.cpp index a7466b7..3a40306 100644 --- a/src/lib/AdapterCommunication.cpp +++ b/src/lib/AdapterCommunication.cpp @@ -110,7 +110,8 @@ void *CAdapterCommunication::Process(void) break; } - CCondition::Sleep(50); + if (!m_bStop) + CCondition::Sleep(50); } m_controller->AddLog(CEC_LOG_DEBUG, "reader thread terminated"); diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 127155a..4a276ee 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -89,14 +89,16 @@ void *CCECProcessor::Process(void) bParseFrame = ParseMessage(msg); } - if (bParseFrame) + if (!m_bStop && bParseFrame) ParseCurrentFrame(); - m_controller->CheckKeypressTimeout(); - CCondition::Sleep(50); + if (!m_bStop) + { + m_controller->CheckKeypressTimeout(); + CCondition::Sleep(50); + } } - m_controller->AddLog(CEC_LOG_DEBUG, "processor thread terminated"); return NULL; } diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 19f34ea..87759c1 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -87,9 +87,17 @@ bool CLibCEC::Open(const char *strPort, int iTimeoutMs /* = 10000 */) void CLibCEC::Close(void) { if (m_cec) + { m_cec->StopThread(); + delete m_cec; + m_cec = NULL; + } if (m_comm) + { m_comm->Close(); + delete m_comm; + m_comm = NULL; + } } int CLibCEC::FindAdapters(std::vector &deviceList, const char *strDevicePath /* = NULL */) diff --git a/src/lib/platform/threads.cpp b/src/lib/platform/threads.cpp index 8933a21..7c5b6ce 100644 --- a/src/lib/platform/threads.cpp +++ b/src/lib/platform/threads.cpp @@ -120,7 +120,7 @@ void CCondition::Sleep(int iTimeout) CCondition w; CMutex m; CLockObject lock(&m); - w.Wait(&m, iTimeout); + w.Wait(&m, int64_t(iTimeout)); } CThread::CThread(void) :