simplified locking

This commit is contained in:
Jeff Hill
2001-06-21 17:16:20 +00:00
parent f2332d1bb1
commit e684ff02eb
3 changed files with 23 additions and 47 deletions

View File

@@ -299,27 +299,15 @@ void cac::processRecvBacklog ()
while ( piiu.valid () ) {
tsDLIterBD < tcpiiu > pNext = piiu;
pNext++;
if ( ! piiu->alive () ) {
assert ( this->pudpiiu && this->pSearchTmr );
piiu->getBHE().unbindFromIIU ();
if ( piiu->channelCount () ) {
char hostNameTmp[64];
piiu->hostName ( hostNameTmp, sizeof ( hostNameTmp ) );
genLocalExcep ( *this, ECA_DISCONN, hostNameTmp );
}
piiu->getBHE().unbindFromIIU ();
assert ( this->pudpiiu );
piiu->disconnectAllChan ( *this->pudpiiu );
// make certain that:
// 1) this is called from the appropriate thread
// 2) lock is not held while in call back
if ( ! this->enablePreemptiveCallback ) {
epicsAutoMutexRelease autoRelease ( this->mutex );
this->notify.fdWasDestroyed ( piiu->getSock() );
}
this->iiuList.remove ( *piiu );
deadIIU.add ( *piiu ); // postpone destroy and avoid deadlock
}
@@ -333,7 +321,6 @@ void cac::processRecvBacklog ()
}
piiu->processIncoming ();
}
piiu = pNext;
}
}
@@ -341,9 +328,16 @@ void cac::processRecvBacklog ()
{
epicsAutoMutex autoRelease ( this->mutex );
while ( tcpiiu *piiu = deadIIU.get() ) {
// make certain that:
// 1) this is called from the appropriate thread
// 2) lock is not held while in call back
if ( ! this->enablePreemptiveCallback ) {
this->notify.fdWasDestroyed ( piiu->getSock() );
}
piiu->destroy ();
}
}
assert ( this->pSearchTmr );
this->pSearchTmr->resetPeriod ( 0.0 );
}
}
@@ -687,27 +681,14 @@ void cac::startRecvProcessThread ()
void cac::run ()
{
epicsAutoMutex autoMutex ( this->mutex );
this->attachToClientCtx ();
while ( ! this->recvProcessThreadExitRequest ) {
{
if ( this->recvProcessEnableRefCount ) {
this->recvProcessInProgress = true;
}
}
if ( this->recvProcessInProgress ) {
if ( this->recvProcessEnableRefCount ) {
this->recvProcessInProgress = true;
this->processRecvBacklog ();
}
bool signalNeeded;
{
this->recvProcessInProgress = false;
signalNeeded = this->recvProcessCompletionNBlockers > 0u;
}
bool signalNeeded = this->recvProcessCompletionNBlockers > 0u;
{
epicsAutoMutexRelease autoRelease ( this->mutex );
if ( signalNeeded ) {

View File

@@ -295,11 +295,13 @@ inline void cac::attachToClientCtx ()
inline char * cac::allocateSmallBufferTCP ()
{
// this locks internally
return ( char * ) freeListMalloc ( this->tcpSmallRecvBufFreeList );
}
inline void cac::releaseSmallBufferTCP ( char *pBuf )
{
// this locks internally
freeListFree ( this->tcpSmallRecvBufFreeList, pBuf );
}
@@ -310,11 +312,13 @@ inline unsigned cac::largeBufferSizeTCP () const
inline char * cac::allocateLargeBufferTCP ()
{
// this locks internally
return ( char * ) freeListMalloc ( this->tcpLargeRecvBufFreeList );
}
inline void cac::releaseLargeBufferTCP ( char *pBuf )
{
// this locks internally
freeListFree ( this->tcpLargeRecvBufFreeList, pBuf );
}

View File

@@ -637,23 +637,14 @@ tcpiiu::~tcpiiu ()
}
}
/*
* free message body cache
*/
{
epicsAutoMutex autoMutex ( this->pCAC()->mutexRef() );
if ( this->pCurData ) {
if ( this->curDataMax == MAX_TCP ) {
this->pCAC()->releaseSmallBufferTCP ( this->pCurData );
}
else {
this->pCAC()->releaseLargeBufferTCP ( this->pCurData );
}
// free message body cache
if ( this->pCurData ) {
if ( this->curDataMax == MAX_TCP ) {
this->pCAC()->releaseSmallBufferTCP ( this->pCurData );
}
else {
this->pCAC()->releaseLargeBufferTCP ( this->pCurData );
}
this->sendQue.clear ();
this->recvQue.clear ();
}
// wakeup user threads blocking for send backlog to be reduced