From dff724cbb505c02d707eda7c12c92bd23fc088c9 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Wed, 9 Feb 2011 22:19:14 +0100 Subject: [PATCH] pvRequest must be destroyed by a client code --- pvAccessApp/remoteClient/clientContextImpl.cpp | 16 +++++++++------- testApp/remote/testRemoteClientImpl.cpp | 7 ++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/pvAccessApp/remoteClient/clientContextImpl.cpp b/pvAccessApp/remoteClient/clientContextImpl.cpp index 83801e8..8bed96c 100644 --- a/pvAccessApp/remoteClient/clientContextImpl.cpp +++ b/pvAccessApp/remoteClient/clientContextImpl.cpp @@ -262,11 +262,13 @@ namespace epics { virtual void acquire() { Lock guard(&m_mutex); m_refCount++; + printf("acquire %d\n", m_refCount); } virtual void release() { m_mutex.lock(); m_refCount--; + printf("release %d\n", m_refCount); m_mutex.unlock(); if (m_refCount == 0) delete this; @@ -303,7 +305,7 @@ namespace epics { ~ChannelProcessRequestImpl() { PVDATA_REFCOUNT_MONITOR_DESTRUCT(channelProcess); - if (m_pvRequest) delete m_pvRequest; + //if (m_pvRequest) delete m_pvRequest; } public: @@ -422,7 +424,7 @@ namespace epics { // synced by code calling this if (m_data) delete m_data; if (m_bitSet) delete m_bitSet; - if (m_pvRequest) delete m_pvRequest; + //if (m_pvRequest) delete m_pvRequest; } public: @@ -567,7 +569,7 @@ namespace epics { // synced by code calling this if (m_data) delete m_data; if (m_bitSet) delete m_bitSet; - if (m_pvRequest) delete m_pvRequest; + //if (m_pvRequest) delete m_pvRequest; } public: @@ -739,7 +741,7 @@ namespace epics { // synced by code calling this if (m_putData) delete m_putData; if (m_getData) delete m_getData; - if (m_pvRequest) delete m_pvRequest; + //if (m_pvRequest) delete m_pvRequest; } public: @@ -954,7 +956,7 @@ namespace epics { // synced by code calling this if (m_data) delete m_data; if (m_bitSet) delete m_bitSet; - if (m_pvRequest) delete m_pvRequest; + //if (m_pvRequest) delete m_pvRequest; } public: @@ -1102,7 +1104,7 @@ namespace epics { PVDATA_REFCOUNT_MONITOR_DESTRUCT(channelArray); // synced by code calling this if (m_data) delete m_data; - if (m_pvRequest) delete m_pvRequest; + //if (m_pvRequest) delete m_pvRequest; } public: @@ -1481,7 +1483,7 @@ namespace epics { PVDATA_REFCOUNT_MONITOR_DESTRUCT(channelMonitor); // synced by code calling this - if (m_pvRequest) delete m_pvRequest; + //if (m_pvRequest) delete m_pvRequest; // uncomment when m_pvStructure not destroyed if (m_structure) m_structure->decReferenceCount(); // TODO temp diff --git a/testApp/remote/testRemoteClientImpl.cpp b/testApp/remote/testRemoteClientImpl.cpp index 6d6b28d..0c95fdc 100644 --- a/testApp/remote/testRemoteClientImpl.cpp +++ b/testApp/remote/testRemoteClientImpl.cpp @@ -489,7 +489,7 @@ int main(int argc,char *argv[]) epicsThreadSleep ( 3.0 ); channelGet->destroy(); - epicsThreadSleep ( 1.0 ); + delete pvRequest; ChannelPutRequesterImpl channelPutRequesterImpl; pvRequest = getCreateRequest()->createRequest("field(value,timeStamp)",&channelPutRequesterImpl); @@ -500,6 +500,7 @@ int main(int argc,char *argv[]) channelPut->put(false); epicsThreadSleep ( 1.0 ); channelPut->destroy(); + delete pvRequest; ChannelPutGetRequesterImpl channelPutGetRequesterImpl; pvRequest = getCreateRequest()->createRequest("putField(value,timeStamp)getField(timeStamp)",&channelPutGetRequesterImpl); @@ -512,6 +513,7 @@ int main(int argc,char *argv[]) channelPutGet->putGet(false); epicsThreadSleep ( 1.0 ); channelPutGet->destroy(); + delete pvRequest; ChannelRPCRequesterImpl channelRPCRequesterImpl; @@ -521,6 +523,7 @@ int main(int argc,char *argv[]) channelRPC->request(false); epicsThreadSleep ( 1.0 ); channelRPC->destroy(); + delete pvRequest; ChannelArrayRequesterImpl channelArrayRequesterImpl; //pvRequest = getCreateRequest()->createRequest("value",&channelArrayRequesterImpl); @@ -538,6 +541,7 @@ int main(int argc,char *argv[]) channelArray->setLength(false,3,4); epicsThreadSleep ( 1.0 ); channelArray->destroy(); + delete pvRequest; MonitorRequesterImpl monitorRequesterImpl; pvRequest = getCreateRequest()->createRequest("field()",&monitorRequesterImpl); @@ -557,6 +561,7 @@ int main(int argc,char *argv[]) monitor->destroy(); + delete pvRequest; epicsThreadSleep ( 3.0 ); printf("Destroying channel... \n");