From 2430736ff134cedf5bef7b8d3f4285906576802a Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 17 Apr 2003 00:07:50 +0000 Subject: [PATCH] patch for fdManager based client tool lock up problems --- src/ca/cac.cpp | 25 ++++++++----------------- src/ca/cac.h | 3 +-- src/ca/tcpiiu.cpp | 11 ++++++++++- src/ca/udpiiu.cpp | 8 ++++---- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/ca/cac.cpp b/src/ca/cac.cpp index c14664da9..7650469ff 100644 --- a/src/ca/cac.cpp +++ b/src/ca/cac.cpp @@ -1152,7 +1152,7 @@ bool cac::readNotifyRespAction ( epicsGuard < callbackMutex > &, tcpiiu &iiu, return true; } -bool cac::eventRespAction (epicsGuard < callbackMutex > &, tcpiiu &iiu, +bool cac::eventRespAction ( epicsGuard < callbackMutex > &, tcpiiu &iiu, const epicsTime &, const caHdrLargeArray & hdr, void * pMsgBdy ) { int caStatus; @@ -1505,13 +1505,7 @@ void cac::disconnectNotify ( tcpiiu & iiu ) void cac::initiateAbortShutdown ( tcpiiu & iiu ) { - // generate some NOOP UDP traffic so that ca_pend_event() - // will get called in preemptive callback disabled - // applications, and therefore the callback lock below - // will not block - if ( this->pudpiiu ) { - this->pudpiiu->wakeupMsg (); - } + cacMessageProcessingMinder msgProcMinder ( *this ); { epicsGuard < callbackMutex > cbGuard ( this->cbMutex ); epicsGuard < cacMutex > guard ( this->mutex ); @@ -1519,13 +1513,7 @@ void cac::initiateAbortShutdown ( tcpiiu & iiu ) } } -void cac::uninstallIIU ( tcpiiu & iiu ) -{ - epicsGuard < callbackMutex > cbGuard ( this->cbMutex ); - this->privateUninstallIIU ( cbGuard, iiu ); -} - -void cac::privateUninstallIIU ( epicsGuard < callbackMutex > & cbGuard, tcpiiu & iiu ) +void cac::uninstallIIU ( epicsGuard < callbackMutex > & cbGuard, tcpiiu & iiu ) { epicsGuard < cacMutex > guard ( this->mutex ); if ( iiu.channelCount() ) { @@ -1593,8 +1581,11 @@ void cac::pvMultiplyDefinedNotify ( msgForMultiplyDefinedPV & mfmdpv, sprintf ( buf, "Channel: \"%.64s\", Connecting to: %.64s, Ignored: %.64s", pChannelName, pAcc, pRej ); { - epicsGuard < callbackMutex > cbGuard ( this->cbMutex ); - this->exception ( cbGuard, ECA_DBLCHNL, buf, __FILE__, __LINE__ ); + cacMessageProcessingMinder msgProcMinder ( *this ); + { + epicsGuard < callbackMutex > cbGuard ( this->cbMutex ); + this->exception ( cbGuard, ECA_DBLCHNL, buf, __FILE__, __LINE__ ); + } } mfmdpv.~msgForMultiplyDefinedPV (); this->mdpvFreeList.release ( & mfmdpv ); diff --git a/src/ca/cac.h b/src/ca/cac.h index 9dfcf2f96..b97401e22 100644 --- a/src/ca/cac.h +++ b/src/ca/cac.h @@ -200,7 +200,7 @@ public: static unsigned highestPriorityLevelBelow ( unsigned priority ); void initiateAbortShutdown ( tcpiiu & ); void disconnectNotify ( tcpiiu & ); - void uninstallIIU ( tcpiiu & ); + void uninstallIIU ( epicsGuard < callbackMutex > &, tcpiiu & iiu ); private: localHostName hostNameCache; @@ -264,7 +264,6 @@ private: unsigned beaconAnomalyCount; bool preemptiveCallbackEnabled; - void privateUninstallIIU ( epicsGuard < callbackMutex > &, tcpiiu &iiu ); void run (); void connectAllIO ( epicsGuard < cacMutex > &, nciu &chan ); void disconnectAllIO ( epicsGuard < cacMutex > & locker, nciu & chan, bool enableCallbacks ); diff --git a/src/ca/tcpiiu.cpp b/src/ca/tcpiiu.cpp index 85fca9ef6..d29e10fca 100644 --- a/src/ca/tcpiiu.cpp +++ b/src/ca/tcpiiu.cpp @@ -138,7 +138,16 @@ void tcpSendThread::run () this->thread.exitWaitRelease (); - this->iiu.cacRef.uninstallIIU ( this->iiu ); + { + // only one recv thread at a time may call callbacks + // - pendEvent() blocks until threads waiting for + // this lock get a chance to run + cacMessageProcessingMinder msgProcMinder ( this->iiu.cacRef ); + { + epicsGuard < callbackMutex > guard ( this->cbMutex ); + this->iiu.cacRef.uninstallIIU ( guard, this->iiu ); + } + } delete & this->iiu; } diff --git a/src/ca/udpiiu.cpp b/src/ca/udpiiu.cpp index 5ae3102f3..bc71d307e 100644 --- a/src/ca/udpiiu.cpp +++ b/src/ca/udpiiu.cpp @@ -310,12 +310,12 @@ void udpRecvThread::run () { epicsThreadPrivateSet ( caClientCallbackThreadId, &this->iiu ); - { - epicsGuard < callbackMutex > cbGuard ( this->cbMutex ); - if ( ellCount ( & this->iiu.dest ) == 0 ) { // X aCC 392 + if ( ellCount ( & this->iiu.dest ) == 0 ) { // X aCC 392 + cacMessageProcessingMinder msgProcMinder ( this->iiu.cacRef ); + { + epicsGuard < callbackMutex > cbGuard ( this->cbMutex ); genLocalExcep ( cbGuard, this->iiu.cacRef, ECA_NOSEARCHADDR, NULL ); } - } do {