From 0cea52568262030c8084e1e63daa97a14ac35eb4 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 13 Aug 2009 22:44:30 +0000 Subject: [PATCH] destroy putCallback prior to calling callback in case they delete the channel in the callback --- src/ca/putCallback.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ca/putCallback.cpp b/src/ca/putCallback.cpp index 25beaa4ad..bff1dd8a4 100644 --- a/src/ca/putCallback.cpp +++ b/src/ca/putCallback.cpp @@ -54,11 +54,13 @@ void putCallback::completion ( epicsGuard < epicsMutex > & guard ) args.status = ECA_NORMAL; args.dbr = 0; caEventCallBackFunc * pFuncTmp = this->pFunc; + // fetch client context and destroy prior to releasing + // the lock and calling cb in case they destroy channel there + this->chan.getClientCtx().destroyPutCallback ( guard, *this ); { epicsGuardRelease < epicsMutex > unguard ( guard ); ( *pFuncTmp ) ( args ); } - this->chan.getClientCtx().destroyPutCallback ( guard, *this ); } void putCallback::exception ( @@ -75,12 +77,17 @@ void putCallback::exception ( args.status = status; args.dbr = 0; caEventCallBackFunc * pFuncTmp = this->pFunc; + // fetch client context and destroy prior to releasing + // the lock and calling cb in case they destroy channel there + this->chan.getClientCtx().destroyPutCallback ( guard, *this ); { epicsGuardRelease < epicsMutex > unguard ( guard ); - ( *pFuncTmp ) (args); + ( *pFuncTmp ) ( args ); } } - this->chan.getClientCtx().destroyPutCallback ( guard, *this ); + else { + this->chan.getClientCtx().destroyPutCallback ( guard, *this ); + } } void * putCallback::operator new ( size_t ) // X aCC 361