diff --git a/src/ca/cac.cpp b/src/ca/cac.cpp index 0455c6e4f..9461b79b4 100644 --- a/src/ca/cac.cpp +++ b/src/ca/cac.cpp @@ -121,7 +121,8 @@ cac::cac ( cacNotify ¬ifyIn, bool enablePreemptiveCallbackIn ) : readSeq ( 0u ), enablePreemptiveCallback ( enablePreemptiveCallbackIn ), ioInProgress ( false ), - recvProcessThreadExitRequest ( false ) + recvProcessThreadExitRequest ( false ), + recvProcessPending ( false ) { long status; unsigned abovePriority; @@ -599,6 +600,10 @@ int cac::pendEvent ( const double &timeout ) else if ( timeout >= CAC_SIGNIFICANT_SELECT_DELAY ) { epicsThreadSleep ( timeout ); } + // give up the processor if there is recv processing to be done + else if ( this->recvProcessPending ) { + epicsThreadSleep ( timeout ); + } } this->disableCallbackPreemption (); @@ -683,9 +688,11 @@ void cac::run () this->attachToClientCtx (); while ( ! this->recvProcessThreadExitRequest ) { { + this->recvProcessPending = true; epicsAutoMutex autoMutexPCB ( this->preemptiveCallbackLock ); epicsAutoMutex autoMutex ( this->mutex ); this->processRecvBacklog (); + this->recvProcessPending = false; } this->recvProcessActivityEvent.wait (); } diff --git a/src/ca/cac.h b/src/ca/cac.h index d686fa4c4..2acc15afa 100644 --- a/src/ca/cac.h +++ b/src/ca/cac.h @@ -184,6 +184,7 @@ private: bool enablePreemptiveCallback; bool ioInProgress; bool recvProcessThreadExitRequest; + bool recvProcessPending; void processRecvBacklog (); void flushRequestPrivate ();