From 02656af9229aa028183292c61ac1345fe642c649 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Wed, 6 Apr 2016 14:00:17 +0200 Subject: [PATCH] "monitor reconnect of different type channel" fix In addition Monitor::release method checks if structure is of the right type. References #40. --- src/remoteClient/clientContextImpl.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/remoteClient/clientContextImpl.cpp b/src/remoteClient/clientContextImpl.cpp index fe99130..d6e0910 100644 --- a/src/remoteClient/clientContextImpl.cpp +++ b/src/remoteClient/clientContextImpl.cpp @@ -2149,8 +2149,11 @@ public: // reuse on reconnect if (m_lastStructure.get() == 0 || - *(m_lastStructure.get()) == *(structure.get())) + *(m_lastStructure.get()) != *(structure.get())) { + while (!m_monitorQueue.empty()) + m_monitorQueue.pop(); + m_freeQueue.clear(); for (int32 i = 0; i < m_queueSize; i++) { PVStructure::shared_pointer pvStructure = getPVDataCreate()->createPVStructure(structure); @@ -2266,6 +2269,13 @@ public: // NOTE: a client must always call poll() after release() to check the presence of any new monitor elements virtual void release(MonitorElement::shared_pointer const & monitorElement) { + + // fast sanity check check if monitorElement->pvStructurePtr->getStructure() matches + // not to accept wrong structure (might happen on monitor reconnect with different type) + // silent return + if (monitorElement->pvStructurePtr->getStructure().get() != m_lastStructure.get()) + return; + bool sendAck = false; { Lock guard(m_mutex);