diff --git a/pvAccessApp/remoteClient/clientContextImpl.cpp b/pvAccessApp/remoteClient/clientContextImpl.cpp index 71a5920..83801e8 100644 --- a/pvAccessApp/remoteClient/clientContextImpl.cpp +++ b/pvAccessApp/remoteClient/clientContextImpl.cpp @@ -1472,7 +1472,7 @@ namespace epics { BitSet* m_overrunBitSet; - int m_count; + bool m_gotMonitor; Mutex m_lock; private: @@ -1500,7 +1500,7 @@ namespace epics { m_monitorRequester(monitorRequester), m_structure(0), m_started(false), m_pvRequest(pvRequest), //(dynamic_cast(getPVDataCreate()->createPVField(0, "", pvRequest))), - m_pvStructure(0), m_count(0) + m_pvStructure(0), m_gotMonitor(false) { PVDATA_REFCOUNT_MONITOR_CONSTRUCT(channelMonitor); @@ -1580,6 +1580,10 @@ namespace epics { m_changedBitSet->deserialize(payloadBuffer, transport); m_pvStructure->deserialize(payloadBuffer, transport, m_changedBitSet); m_overrunBitSet->deserialize(payloadBuffer, transport); + + m_lock.lock(); + m_gotMonitor = true; + m_lock.unlock(); EXCEPTION_GUARD(m_monitorRequester->monitorEvent(this)); } @@ -1689,22 +1693,14 @@ namespace epics { virtual MonitorElement* poll() { Lock xx(&m_lock); - if (m_count) - { - return 0; - } - else - { - m_count++; - return this; - } + if (!m_gotMonitor) return 0; + return this; } virtual void release(MonitorElement* monitorElement) { Lock xx(&m_lock); - if (m_count) - m_count--; + m_gotMonitor = false; } // ============ MonitorElement ============ diff --git a/testApp/remote/testRemoteClientImpl.cpp b/testApp/remote/testRemoteClientImpl.cpp index caac4cd..6d6b28d 100644 --- a/testApp/remote/testRemoteClientImpl.cpp +++ b/testApp/remote/testRemoteClientImpl.cpp @@ -468,7 +468,7 @@ int main(int argc,char *argv[]) channel->printInfo(); PVStructure* pvRequest; -/* + GetFieldRequesterImpl getFieldRequesterImpl; channel->getField(&getFieldRequesterImpl, ""); epicsThreadSleep ( 1.0 ); @@ -480,7 +480,7 @@ int main(int argc,char *argv[]) epicsThreadSleep ( 1.0 ); channelProcess->destroy(); epicsThreadSleep ( 1.0 ); -*/ + ChannelGetRequesterImpl channelGetRequesterImpl; pvRequest = getCreateRequest()->createRequest("field()",&channelGetRequesterImpl); ChannelGet* channelGet = channel->createChannelGet(&channelGetRequesterImpl, pvRequest); @@ -490,7 +490,7 @@ int main(int argc,char *argv[]) channelGet->destroy(); epicsThreadSleep ( 1.0 ); -/* + ChannelPutRequesterImpl channelPutRequesterImpl; pvRequest = getCreateRequest()->createRequest("field(value,timeStamp)",&channelPutRequesterImpl); ChannelPut* channelPut = channel->createChannelPut(&channelPutRequesterImpl, pvRequest); @@ -557,7 +557,7 @@ int main(int argc,char *argv[]) monitor->destroy(); - */ + epicsThreadSleep ( 3.0 ); printf("Destroying channel... \n"); channel->destroy();