From 235f23a322edaed32bb336053ca472a9ebc6a110 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 14 Aug 2002 21:53:30 +0000 Subject: [PATCH] fixed deadlock --- src/cas/generic/casEventSys.cc | 81 ++++++++++++++++------------------ 1 file changed, 37 insertions(+), 44 deletions(-) diff --git a/src/cas/generic/casEventSys.cc b/src/cas/generic/casEventSys.cc index 2e58b446b..64ef3e422 100644 --- a/src/cas/generic/casEventSys.cc +++ b/src/cas/generic/casEventSys.cc @@ -96,56 +96,49 @@ casProcCond casEventSys::process () unsigned long nAccepted = 0u; { - epicsGuard < epicsMutex > guard ( this->mutex ); - while (!this->dontProcess) { + while ( ! this->dontProcess ) { - casEvent *pEvent = this->eventLogQue.get (); - if ( pEvent == NULL ) { - break; - } + { + epicsGuard < epicsMutex > guard ( this->mutex ); + casEvent * pEvent = this->eventLogQue.get (); + } - // - // lock must remain on until the event queue - // event is called - // + if ( pEvent == NULL ) { + break; + } - caStatus status = pEvent->cbFunc ( *this ); - if ( status == S_cas_success ) { - /* - * only remove it after it was accepted by the - * client - */ - nAccepted++; - } - else if ( status == S_cas_sendBlocked ) { - /* - * not accepted so return to the head of the list - * (we will try again later) - */ + // lock must remain on until the event is called + caStatus status = pEvent->cbFunc ( *this ); + if ( status == S_cas_success ) { + nAccepted++; + } + else if ( status == S_cas_sendBlocked ) { + // not accepted so return to the head of the list + // (we will try again later) + { + epicsGuard < epicsMutex > guard ( this->mutex ); this->pushOnToEventQueue ( *pEvent ); - cond = casProcOk; - break; - } - else if ( status == S_cas_disconnect ) { - cond = casProcDisconnect; - break; - } - else { - errMessage ( status, - "- unexpected error processing event" ); - cond = casProcDisconnect; - break; - } - } + } + cond = casProcOk; + break; + } + else if ( status == S_cas_disconnect ) { + cond = casProcDisconnect; + break; + } + else { + errMessage ( status, + "- unexpected error processing event" ); + cond = casProcDisconnect; + break; + } + } - /* - * call flush function if they provided one - */ - if ( nAccepted > 0u ) { - this->eventFlush (); - } - } + // call flush function if they provided one + if ( nAccepted > 0u ) { + this->eventFlush (); + } // // allows the derived class to be informed that it