From: Lars Op den Kamp Date: Tue, 6 Dec 2011 23:40:01 +0000 (+0100) Subject: cec: fixed another deadlock on exit X-Git-Tag: upstream/2.2.0~1^2~44^2~26 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a0878ee3c123121dddc0103ba6b7d320b5416151;p=deb_libcec.git cec: fixed another deadlock on exit --- diff --git a/src/lib/AdapterCommunication.cpp b/src/lib/AdapterCommunication.cpp index 5541bf5..2bdbb04 100644 --- a/src/lib/AdapterCommunication.cpp +++ b/src/lib/AdapterCommunication.cpp @@ -328,6 +328,10 @@ void *CAdapterCommunication::Process(void) WriteNextCommand(); } + CCECAdapterMessage *msg; + if (m_outBuffer.Pop(msg)) + msg->condition.Broadcast(); + return NULL; } diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 4df840d..1daa7b6 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -118,14 +118,6 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con CCECProcessor::~CCECProcessor(void) { m_bStarted = false; - StopThread(false); - - if (m_busScan) - { - m_busScan->StopThread(); - delete m_busScan; - } - m_startCondition.Broadcast(); StopThread(); @@ -304,6 +296,13 @@ void *CCECProcessor::Process(void) m_controller->CheckKeypressTimeout(); } + if (m_busScan) + { + m_busScan->StopThread(); + delete m_busScan; + m_busScan = NULL; + } + if (m_communication) m_communication->Close(); diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 6d775f5..75196ea 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -127,7 +127,6 @@ namespace CEC CCECBusDevice *m_busDevices[16]; CMutex m_transmitMutex; - uint64_t m_iLastTransmission; private: void ScanCECBus(void); @@ -162,13 +161,14 @@ namespace CEC uint8_t m_iLineTimeout; uint8_t m_iStandardLineTimeout; uint8_t m_iRetryLineTimeout; + uint64_t m_iLastTransmission; }; class CCECBusScan : public CThread { public: CCECBusScan(CCECProcessor *processor) { m_processor = processor; } - virtual ~CCECBusScan(void) {} + virtual ~CCECBusScan(void) { StopThread(true); } virtual void *Process(void); private: