diff --git a/src/ca/ca_client_context.cpp b/src/ca/ca_client_context.cpp index a140b769e..35e9c9f2f 100644 --- a/src/ca/ca_client_context.cpp +++ b/src/ca/ca_client_context.cpp @@ -185,21 +185,31 @@ ca_client_context::~ca_client_context () } } +void ca_client_context::destroyChannelPrivate ( + oldChannelNotify & chan, + epicsGuard < epicsMutex > & cbGuard ) +{ + epicsGuard < epicsMutex > guard ( this->mutex ); + try { + chan.eliminateExcessiveSendBacklog ( + &cbGuard, guard ); + } + catch ( cacChannel::notConnected & ) { + // intentionally ignored + } + chan.destructor ( cbGuard, guard ); + this->oldChannelNotifyFreeList.release ( & chan ); +} + void ca_client_context::destroyChannel ( oldChannelNotify & chan ) { - if ( this->pCallbackGuard.get() ) { - epicsGuard < epicsMutex > guard ( this->mutex ); - chan.eliminateExcessiveSendBacklog ( - this->pCallbackGuard.get(), guard ); - chan.destructor ( *this->pCallbackGuard.get(), guard ); - this->oldChannelNotifyFreeList.release ( & chan ); + epicsGuard < epicsMutex > * pCBGuard = this->pCallbackGuard.get(); + if ( pCBGuard ) { + destroyChannelPrivate ( chan, *pCBGuard ); } else { epicsGuard < epicsMutex > cbGuard ( this->cbMutex ); - epicsGuard < epicsMutex > guard ( this->mutex ); - chan.eliminateExcessiveSendBacklog ( &cbGuard, guard ); - chan.destructor ( cbGuard, guard ); - this->oldChannelNotifyFreeList.release ( & chan ); + destroyChannelPrivate ( chan, cbGuard ); } } @@ -227,6 +237,21 @@ void ca_client_context::destroyPutCallback ( this->putCallbackFreeList.release ( & pcb ); } +void ca_client_context::clearSubscriptionPrivate ( + evid pMon, epicsGuard < epicsMutex > & cbGuard ) +{ + epicsGuard < epicsMutex > guard ( this->mutex ); + oldChannelNotify & chan = pMon->channel (); + try { + chan.eliminateExcessiveSendBacklog ( + &cbGuard, guard ); + } + catch ( cacChannel::notConnected & ) { + // intentionally ignored + } + pMon->ioCancel ( cbGuard, guard ); +} + void ca_client_context::destroySubscription ( epicsGuard < epicsMutex > & guard, oldSubscription & os ) { diff --git a/src/ca/oldAccess.h b/src/ca/oldAccess.h index ff6d4acfe..e10557a47 100644 --- a/src/ca/oldAccess.h +++ b/src/ca/oldAccess.h @@ -365,6 +365,11 @@ private: void callbackProcessingCompleteNotify (); cacContext & createNetworkContext ( epicsMutex & mutualExclusion, epicsMutex & callbackControl ); + void destroyChannelPrivate ( + oldChannelNotify & chan, epicsGuard < epicsMutex > & cbGuard ); + void clearSubscriptionPrivate ( + evid pMon, epicsGuard < epicsMutex > & cbGuard ); + ca_client_context ( const ca_client_context & ); ca_client_context & operator = ( const ca_client_context & );