diff --git a/src/ca/oldCAC.cpp b/src/ca/oldCAC.cpp index 7436326f1..d0d7083ed 100644 --- a/src/ca/oldCAC.cpp +++ b/src/ca/oldCAC.cpp @@ -228,13 +228,8 @@ void oldCAC::incrementOutstandingIO ( unsigned ioSeqNoIn ) if ( this->ioSeqNo == ioSeqNoIn ) { epicsGuard < oldCACMutex > guard ( this->mutex ); if ( this->ioSeqNo == ioSeqNoIn ) { - if ( this->pndRecvCnt < UINT_MAX ) { - this->pndRecvCnt++; - } - else { - throw std::logic_error ( - "oldCAC::incrementOutstandingIO() IO counter overflow" ); - } + assert ( this->pndRecvCnt < UINT_MAX ); + this->pndRecvCnt++; } } } @@ -249,17 +244,13 @@ void oldCAC::decrementOutstandingIO ( unsigned ioSeqNoIn ) { epicsGuard < oldCACMutex > guard ( this->mutex ); if ( this->ioSeqNo == ioSeqNoIn ) { - if ( this->pndRecvCnt > 0u ) { - this->pndRecvCnt--; - if ( this->pndRecvCnt == 0u ) { - signalNeeded = true; - } - else { - signalNeeded = false; - } + assert ( this->pndRecvCnt > 0u ); + this->pndRecvCnt--; + if ( this->pndRecvCnt == 0u ) { + signalNeeded = true; } else { - signalNeeded = true; + signalNeeded = false; } } else { diff --git a/src/ca/oldChannelNotify.cpp b/src/ca/oldChannelNotify.cpp index 7c0cb5148..dd6e5a4e6 100644 --- a/src/ca/oldChannelNotify.cpp +++ b/src/ca/oldChannelNotify.cpp @@ -38,7 +38,7 @@ oldChannelNotify::oldChannelNotify ( oldCAC & cacIn, const char *pName, pConnCallBack ( pConnCallBackIn ), pPrivate ( pPrivateIn ), pAccessRightsFunc ( cacNoopAccesRightsHandler ), ioSeqNo ( cacIn.sequenceNumberOfOutstandingIO () ), - prevConnected ( false ) + currentlyConnected ( false ), prevConnected ( false ) { // no need to worry about a connect preempting here because // the connect sequence will not start untill initiateConnect() @@ -50,12 +50,13 @@ oldChannelNotify::oldChannelNotify ( oldCAC & cacIn, const char *pName, oldChannelNotify::~oldChannelNotify () { - delete & this->io; // no need to worry about a connect preempting here because - // the nciu as been deleted - this->cacCtx.decrementOutstandingIO ( this->ioSeqNo ); + // the nciu has been deleted + if ( this->pConnCallBack == 0 && ! this->currentlyConnected ) { + this->cacCtx.decrementOutstandingIO ( this->ioSeqNo ); + } } void oldChannelNotify::setPrivatePointer ( void *pPrivateIn ) @@ -76,7 +77,7 @@ int oldChannelNotify::replaceAccessRightsEvent ( caArh *pfunc ) // handler could be called twice here with the same access rights state, but // that will not upset the application. this->pAccessRightsFunc = pfunc ? pfunc : cacNoopAccesRightsHandler; - if ( this->io.connected () ) { + if ( this->currentlyConnected ) { struct access_rights_handler_args args; args.chid = this; caAccessRights tmp = this->io.accessRights (); @@ -92,7 +93,7 @@ int oldChannelNotify::changeConnCallBack ( caCh * pfunc ) epicsGuard < callbackMutex > callbackGuard = this->cacCtx.callbackGuardFactory (); - if ( ! this->prevConnected ) { + if ( ! this->currentlyConnected ) { if ( pfunc ) { if ( ! this->pConnCallBack ) { this->cacCtx.decrementOutstandingIO ( this->ioSeqNo ); @@ -111,6 +112,7 @@ int oldChannelNotify::changeConnCallBack ( caCh * pfunc ) void oldChannelNotify::connectNotify () { + this->currentlyConnected = true; this->prevConnected = true; if ( this->pConnCallBack ) { struct connection_handler_args args; @@ -127,6 +129,7 @@ void oldChannelNotify::connectNotify () void oldChannelNotify::disconnectNotify () { + this->currentlyConnected = false; if ( this->pConnCallBack ) { struct connection_handler_args args; args.chid = this;