From 784c6665a6ba15fd72ec5915d4a66aa64b6fc6b7 Mon Sep 17 00:00:00 2001 From: mrkraimer Date: Tue, 14 Nov 2017 09:11:27 -0500 Subject: [PATCH] make pvRequest weak_pointer for get, put, and monitor --- src/ca/caChannel.cpp | 18 +++++++++++++++--- src/ca/caChannel.h | 6 +++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/ca/caChannel.cpp b/src/ca/caChannel.cpp index a16285c..d69d0f4 100644 --- a/src/ca/caChannel.cpp +++ b/src/ca/caChannel.cpp @@ -672,7 +672,7 @@ CAChannelGet::CAChannelGet(CAChannel::shared_pointer const & channel, : channel(channel), channelGetRequester(channelGetRequester), - pvRequest(pvRequest) + pvRequestWeak(pvRequest) { if(DEBUG_LEVEL>0) { cout << "CAChannelGet::CAChannelGet() " << channel->getChannelName() << endl; @@ -693,6 +693,8 @@ void CAChannelGet::activate() } ChannelGetRequester::shared_pointer getRequester(channelGetRequester.lock()); if(!getRequester) return; + PVStructurePtr pvRequest(pvRequestWeak.lock()); + if(!pvRequest) return; if(pvStructure) throw std::runtime_error("CAChannelGet::activate() was called twice"); getType = getDBRType(pvRequest, channel->getNativeType()); pvStructure = createPVStructure(channel, getType, pvRequest); @@ -712,6 +714,8 @@ void CAChannelGet::channelCreated(const Status& status,Channel::shared_pointer c } ChannelGetRequester::shared_pointer getRequester(channelGetRequester.lock()); if(!getRequester) return; + PVStructurePtr pvRequest(pvRequestWeak.lock()); + if(!pvRequest) return; chtype newType = getDBRType(pvRequest, channel->getNativeType()); if(newType!=getType) { getType = getDBRType(pvRequest, channel->getNativeType()); @@ -1211,7 +1215,7 @@ CAChannelPut::CAChannelPut(CAChannel::shared_pointer const & channel, : channel(channel), channelPutRequester(channelPutRequester), - pvRequest(pvRequest), + pvRequestWeak(pvRequest), block(false) { if(DEBUG_LEVEL>0) { @@ -1226,6 +1230,8 @@ void CAChannelPut::activate() } ChannelPutRequester::shared_pointer putRequester(channelPutRequester.lock()); if(!putRequester) return; + PVStructurePtr pvRequest(pvRequestWeak.lock()); + if(!pvRequest) return; if(pvStructure) throw std::runtime_error("CAChannelPut::activate() was called twice"); getType = getDBRType(pvRequest,channel->getNativeType()); pvStructure = createPVStructure(channel, getType, pvRequest); @@ -1251,6 +1257,8 @@ void CAChannelPut::channelCreated(const Status& status,Channel::shared_pointer c } ChannelPutRequester::shared_pointer putRequester(channelPutRequester.lock()); if(!putRequester) return; + PVStructurePtr pvRequest(pvRequestWeak.lock()); + if(!pvRequest) return; chtype newType = getDBRType(pvRequest, channel->getNativeType()); if(newType!=getType) { getType = getDBRType(pvRequest, channel->getNativeType()); @@ -1736,7 +1744,7 @@ CAChannelMonitor::CAChannelMonitor( : channel(channel), monitorRequester(monitorRequester), - pvRequest(pvRequest), + pvRequestWeak(pvRequest), isStarted(false) { if(DEBUG_LEVEL>0) { @@ -1751,6 +1759,8 @@ void CAChannelMonitor::activate() } MonitorRequester::shared_pointer requester(monitorRequester.lock()); if(!requester) return; + PVStructurePtr pvRequest(pvRequestWeak.lock()); + if(!pvRequest) return; if(pvStructure) throw std::runtime_error("CAChannelMonitor::activate() was called twice"); getType = getDBRType(pvRequest, channel->getNativeType()); pvStructure = createPVStructure(channel, getType, pvRequest); @@ -1781,6 +1791,8 @@ void CAChannelMonitor::channelCreated(const Status& status,Channel::shared_point } MonitorRequester::shared_pointer requester(monitorRequester.lock()); if(!requester) return; + PVStructurePtr pvRequest(pvRequestWeak.lock()); + if(!pvRequest) return; chtype newType = getDBRType(pvRequest, channel->getNativeType()); if(newType!=getType) { getType = getDBRType(pvRequest, channel->getNativeType()); diff --git a/src/ca/caChannel.h b/src/ca/caChannel.h index 8fd3120..80c2604 100644 --- a/src/ca/caChannel.h +++ b/src/ca/caChannel.h @@ -180,7 +180,7 @@ private: CAChannelPtr channel; ChannelGetRequester::weak_pointer channelGetRequester; - epics::pvData::PVStructure::shared_pointer pvRequest; + epics::pvData::PVStructure::weak_pointer pvRequestWeak; chtype getType; epics::pvData::PVStructure::shared_pointer pvStructure; @@ -248,7 +248,7 @@ private: CAChannelPtr channel; ChannelPutRequester::weak_pointer channelPutRequester; - epics::pvData::PVStructure::shared_pointer pvRequest; + epics::pvData::PVStructure::weak_pointer pvRequestWeak; bool block; chtype getType; @@ -310,7 +310,7 @@ private: CAChannelPtr channel; MonitorRequester::weak_pointer monitorRequester; - epics::pvData::PVStructure::shared_pointer pvRequest; + epics::pvData::PVStructure::weak_pointer pvRequestWeak; bool isStarted; chtype getType;