diff --git a/src/remoteClient/clientContextImpl.cpp b/src/remoteClient/clientContextImpl.cpp index 1c9d392..71cccfa 100644 --- a/src/remoteClient/clientContextImpl.cpp +++ b/src/remoteClient/clientContextImpl.cpp @@ -3305,7 +3305,40 @@ private: virtual void destroy() OVERRIDE FINAL { - destroy(false); + { + Lock guard(m_channelMutex); + if (m_connectionState == DESTROYED) + return; + REFTRACE_DECREMENT(num_active); + + m_getfield.reset(); + + // stop searching... + shared_pointer thisChannelPointer = internal_from_this(); + m_context->getChannelSearchManager()->unregisterSearchInstance(thisChannelPointer); + + disconnectPendingIO(true); + + if (m_connectionState == CONNECTED) + { + disconnect(false, true); + } + else if (m_transport) + { + // unresponsive state, do not forget to release transport + m_transport->release(getID()); + m_transport.reset(); + } + + + setConnectionState(DESTROYED); + + // unregister + m_context->unregisterChannel(thisChannelPointer); + } + + // should be called without any lock hold + reportChannelStateChange(); } virtual string getRequesterName() OVERRIDE FINAL @@ -3482,66 +3515,6 @@ public: reportChannelStateChange(); } - /** - * @param force force destruction regardless of reference count (not used now) - */ - void destroy(bool force) { - { - Lock guard(m_channelMutex); - if (m_connectionState == DESTROYED) - return; - //throw std::runtime_error("Channel already destroyed."); - } - REFTRACE_DECREMENT(num_active); - - destroyChannel(force); - } - - - /** - * Actual destroy method, to be called CAJContext. - * @param force force destruction regardless of reference count - * @throws PVAException - * @throws std::runtime_error - * @throws IOException - */ - void destroyChannel(bool /*force*/) OVERRIDE FINAL { - { - Lock guard(m_channelMutex); - - if (m_connectionState == DESTROYED) - throw std::runtime_error("Channel already destroyed."); - - m_getfield.reset(); - - // stop searching... - shared_pointer thisChannelPointer = internal_from_this(); - m_context->getChannelSearchManager()->unregisterSearchInstance(thisChannelPointer); - - disconnectPendingIO(true); - - if (m_connectionState == CONNECTED) - { - disconnect(false, true); - } - else if (m_transport) - { - // unresponsive state, do not forget to release transport - m_transport->release(getID()); - m_transport.reset(); - } - - - setConnectionState(DESTROYED); - - // unregister - m_context->unregisterChannel(thisChannelPointer); - } - - // should be called without any lock hold - reportChannelStateChange(); - } - /** * Disconnected notification. * @param initiateSearch flag to indicate if searching (connect) procedure should be initiated diff --git a/src/remoteClient/pv/clientContextImpl.h b/src/remoteClient/pv/clientContextImpl.h index 0ee0884..a003d65 100644 --- a/src/remoteClient/pv/clientContextImpl.h +++ b/src/remoteClient/pv/clientContextImpl.h @@ -41,7 +41,6 @@ public: POINTER_DEFINITIONS(ClientChannelImpl); virtual pvAccessID getChannelID() = 0; - virtual void destroyChannel(bool force) = 0; virtual void connectionCompleted(pvAccessID sid/*, rights*/) = 0; virtual void createChannelFailed() = 0; virtual ClientContextImpl* getContext() = 0;