From 9e46188c5150b05698d2f9280d03d06fb1592733 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 25 Apr 2002 23:51:20 +0000 Subject: [PATCH] firmed up compile time lock requirements --- src/ca/cac.cpp | 20 +++++++++---------- src/ca/nciu.h | 53 ++++++++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/ca/cac.cpp b/src/ca/cac.cpp index 8b04c5d58..df0eb881c 100644 --- a/src/ca/cac.cpp +++ b/src/ca/cac.cpp @@ -731,7 +731,7 @@ bool cac::lookupChannelAndTransferToTCP ( // disconnects to prevent a race condition with the // code below - ie we hold the callback lock here // so a chanel cant be destroyed out from under us. - pChan->connectStateNotify (); + pChan->connectStateNotify ( cbGuard ); /* * if less than v4.1 then the server will never @@ -740,7 +740,7 @@ bool cac::lookupChannelAndTransferToTCP ( * their call back here */ if ( ! v41Ok ) { - pChan->accessRightsNotify (); + pChan->accessRightsNotify ( cbGuard ); } } @@ -1398,13 +1398,13 @@ bool cac::readExcep ( epicsGuard < callbackMutex > &, tcpiiu &, return true; } -bool cac::writeExcep ( epicsGuard < callbackMutex > &, tcpiiu &, +bool cac::writeExcep ( epicsGuard < callbackMutex > &cbLocker, tcpiiu &, const caHdrLargeArray &hdr, const char *pCtx, unsigned status ) { nciu * pChan = this->chanTable.lookup ( hdr.m_available ); if ( pChan ) { - pChan->writeException ( status, pCtx, + pChan->writeException ( cbLocker, status, pCtx, hdr.m_dataType, hdr.m_count ); } return true; @@ -1468,7 +1468,7 @@ bool cac::exceptionRespAction ( epicsGuard < callbackMutex > & cbMutexIn, tcpiiu return ( this->*pStub ) ( cbMutexIn, iiu, req, pCtx, hdr.m_available ); } -bool cac::accessRightsRespAction ( epicsGuard < callbackMutex > &, tcpiiu &, +bool cac::accessRightsRespAction ( epicsGuard < callbackMutex > & cbGuard, tcpiiu &, const caHdrLargeArray &hdr, void * /* pMsgBdy */ ) { nciu * pChan; @@ -1490,13 +1490,13 @@ bool cac::accessRightsRespAction ( epicsGuard < callbackMutex > &, tcpiiu &, // deleted. // if ( pChan ) { - pChan->accessRightsNotify (); + pChan->accessRightsNotify ( cbGuard ); } return true; } -bool cac::claimCIURespAction ( epicsGuard < callbackMutex > &, tcpiiu & iiu, +bool cac::claimCIURespAction ( epicsGuard < callbackMutex > &cbGuard, tcpiiu & iiu, const caHdrLargeArray & hdr, void * /*pMsgBdy */ ) { nciu * pChan; @@ -1524,7 +1524,7 @@ bool cac::claimCIURespAction ( epicsGuard < callbackMutex > &, tcpiiu & iiu, // the callback lock is taken when a channel is unistalled or when // is disconnected to prevent race conditions here if ( pChan ) { - pChan->connectStateNotify (); + pChan->connectStateNotify ( cbGuard ); } return true; } @@ -1554,8 +1554,8 @@ void cac::disconnectChannel ( epicsGuard < callbackMutex > & cbLocker, chan.disconnect ( *this->pudpiiu ); this->pudpiiu->installChannel ( chan ); epicsGuardRelease < cacMutex > autoMutexRelease ( locker ); - chan.connectStateNotify (); - chan.accessRightsNotify (); + chan.connectStateNotify ( cbLocker ); + chan.accessRightsNotify ( cbLocker ); } bool cac::badTCPRespAction ( epicsGuard < callbackMutex > &, tcpiiu & iiu, diff --git a/src/ca/nciu.h b/src/ca/nciu.h index 5a1dad278..d7d28474a 100644 --- a/src/ca/nciu.h +++ b/src/ca/nciu.h @@ -43,6 +43,7 @@ class cac; class netiiu; +class callbackMutex; class cacPrivateListOfIO { public: @@ -63,8 +64,8 @@ public: void connect ( unsigned nativeType, unsigned nativeCount, unsigned sid, bool v41Ok ); void connect (); - void connectStateNotify () const; - void accessRightsNotify () const; + void connectStateNotify ( epicsGuard < callbackMutex > & ) const; + void accessRightsNotify ( epicsGuard < callbackMutex > & ) const; void disconnect ( netiiu &newiiu ); bool searchMsg ( class udpiiu & iiu, unsigned short retrySeqNumber, unsigned & retryNoForThisChannel ); @@ -91,7 +92,8 @@ public: arrayElementCount nativeElementCount () const; bool connected () const; bool previouslyConnected () const; - void writeException ( int status, const char *pContext, unsigned type, arrayElementCount count ); + void writeException ( epicsGuard < callbackMutex > &, + int status, const char *pContext, unsigned type, arrayElementCount count ); cacChannel::priLev getPriority () const; void notifyStateChangeFirstConnectInCountOfOutstandingIO (); private: @@ -154,7 +156,7 @@ inline void nciu::resetRetryCount () this->retry = 0u; } -inline void nciu::accessRightsStateChange ( const caAccessRights &arIn ) +inline void nciu::accessRightsStateChange ( const caAccessRights & arIn ) { this->accessRightState = arIn; } @@ -204,6 +206,28 @@ inline netiiu * nciu::getPIIU () return this->piiu; } + +inline void nciu::writeException ( epicsGuard < callbackMutex > &, int status, + const char *pContext, unsigned typeIn, arrayElementCount countIn ) +{ + this->notify().writeException ( status, pContext, typeIn, countIn ); +} + +inline void nciu::accessRightsNotify ( epicsGuard < callbackMutex > & ) const +{ + this->notify().accessRightsNotify ( this->accessRightState ); +} + +inline void nciu::connectStateNotify ( epicsGuard < callbackMutex > & ) const +{ + if ( this->f_connected ) { + this->notify().connectNotify (); + } + else { + this->notify().disconnectNotify (); + } +} + inline const netiiu * nciu::getConstPIIU () const { return this->piiu; @@ -219,27 +243,6 @@ inline void nciu::connectTimeoutNotify () this->f_connectTimeOutSeen = true; } -inline void nciu::writeException ( int status, - const char *pContext, unsigned typeIn, arrayElementCount countIn ) -{ - this->notify().writeException ( status, pContext, typeIn, countIn ); -} - -inline void nciu::connectStateNotify () const -{ - if ( this->f_connected ) { - this->notify().connectNotify (); - } - else { - this->notify().disconnectNotify (); - } -} - -inline void nciu::accessRightsNotify () const -{ - this->notify().accessRightsNotify ( this->accessRightState ); -} - inline cacChannel::priLev nciu::getPriority () const { return this->priority;