upgraded locking
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "oldAccess.h"
|
||||
|
||||
tsFreeList < struct CASG, 128 > CASG::freeList;
|
||||
epicsMutex CASG::freeListMutex;
|
||||
|
||||
CASG::CASG (cac &cacIn) :
|
||||
client (cacIn), magic (CASG_MAGIC), opPendCount (0u), seqNo (0u)
|
||||
@@ -46,13 +47,14 @@ void CASG::destroy ()
|
||||
CASG::~CASG ()
|
||||
{
|
||||
if ( this->verify () ) {
|
||||
this->mutex.lock ();
|
||||
tsDLIterBD <syncGroupNotify> notify = this->ioList.firstIter ();
|
||||
while ( notify.valid () ) {
|
||||
notify->release ();
|
||||
notify = this->ioList.firstIter ();
|
||||
{
|
||||
epicsAutoMutex locker ( this->mutex );
|
||||
tsDLIterBD <syncGroupNotify> notify = this->ioList.firstIter ();
|
||||
while ( notify.valid () ) {
|
||||
notify->release ();
|
||||
notify = this->ioList.firstIter ();
|
||||
}
|
||||
}
|
||||
this->mutex.unlock ();
|
||||
this->client.uninstallCASG ( *this );
|
||||
this->magic = 0;
|
||||
}
|
||||
@@ -82,16 +84,6 @@ int CASG::block ( double timeout )
|
||||
return ECA_TIMEOUT;
|
||||
}
|
||||
|
||||
/*
|
||||
* dont allow recursion
|
||||
*/
|
||||
void *p = epicsThreadPrivateGet ( cacRecursionLock );
|
||||
if ( p ) {
|
||||
return ECA_EVDISALLOW;
|
||||
}
|
||||
|
||||
epicsThreadPrivateSet ( cacRecursionLock, &cacRecursionLock );
|
||||
|
||||
cur_time = epicsTime::getCurrent ();
|
||||
|
||||
this->client.flush ();
|
||||
@@ -103,17 +95,16 @@ int CASG::block ( double timeout )
|
||||
|
||||
status = ECA_NORMAL;
|
||||
while ( 1 ) {
|
||||
this->mutex.lock ();
|
||||
if ( this->seqNo != initialSeqNo ) {
|
||||
this->mutex.unlock ();
|
||||
break;
|
||||
{
|
||||
epicsAutoMutex locker ( this->mutex );
|
||||
if ( this->seqNo != initialSeqNo ) {
|
||||
break;
|
||||
}
|
||||
if ( this->opPendCount == 0u ) {
|
||||
this->seqNo++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( this->opPendCount == 0u ) {
|
||||
this->seqNo++;
|
||||
this->mutex.unlock ();
|
||||
break;
|
||||
}
|
||||
this->mutex.unlock ();
|
||||
|
||||
remaining = timeout - delay;
|
||||
if ( remaining <= CAC_SIGNIFICANT_SELECT_DELAY ) {
|
||||
@@ -122,9 +113,10 @@ int CASG::block ( double timeout )
|
||||
* recv backlog at least once
|
||||
*/
|
||||
status = ECA_TIMEOUT;
|
||||
this->mutex.lock ();
|
||||
this->seqNo++;
|
||||
this->mutex.unlock ();
|
||||
{
|
||||
epicsAutoMutex locker ( this->mutex );
|
||||
this->seqNo++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -140,32 +132,28 @@ int CASG::block ( double timeout )
|
||||
|
||||
this->client.disableCallbackPreemption ();
|
||||
|
||||
epicsThreadPrivateSet (cacRecursionLock, NULL);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void CASG::reset ()
|
||||
{
|
||||
this->mutex.lock ();
|
||||
epicsAutoMutex locker ( this->mutex );
|
||||
this->opPendCount = 0;
|
||||
this->seqNo++;
|
||||
this->mutex.unlock ();
|
||||
}
|
||||
|
||||
void CASG::show ( unsigned level) const
|
||||
{
|
||||
printf ("Sync Group: id=%u, magic=%u, opPend=%lu, seqNo=%lu\n",
|
||||
this->getId (), this->magic, this->opPendCount, this->seqNo);
|
||||
printf ( "Sync Group: id=%u, magic=%u, opPend=%lu, seqNo=%lu\n",
|
||||
this->getId (), this->magic, this->opPendCount, this->seqNo );
|
||||
|
||||
if ( level ) {
|
||||
this->mutex.lock ();
|
||||
tsDLIterConstBD <syncGroupNotify> notify = this->ioList.firstIter ();
|
||||
epicsAutoMutex locker ( this->mutex );
|
||||
tsDLIterConstBD < syncGroupNotify > notify = this->ioList.firstIter ();
|
||||
while ( notify.valid () ) {
|
||||
notify->show (level);
|
||||
notify++;
|
||||
}
|
||||
this->mutex.unlock ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,11 +164,13 @@ bool CASG::ioComplete () const
|
||||
|
||||
void * CASG::operator new (size_t size)
|
||||
{
|
||||
epicsAutoMutex locker ( CASG::freeListMutex );
|
||||
return CASG::freeList.allocate ( size );
|
||||
}
|
||||
|
||||
void CASG::operator delete (void *pCadaver, size_t size)
|
||||
{
|
||||
epicsAutoMutex locker ( CASG::freeListMutex );
|
||||
CASG::freeList.release ( pCadaver, size );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,44 +19,37 @@
|
||||
|
||||
epicsShareDef cacServiceList cacGlobalServiceList;
|
||||
|
||||
cacServiceList::cacServiceList ()
|
||||
{
|
||||
}
|
||||
|
||||
void cacServiceList::registerService ( cacServiceIO &service )
|
||||
{
|
||||
this->lock ();
|
||||
epicsAutoMutex locker ( this->mutex );
|
||||
this->services.add ( service );
|
||||
this->unlock ();
|
||||
}
|
||||
|
||||
cacChannelIO * cacServiceList::createChannelIO ( const char *pName,
|
||||
cac &cacCtx, cacChannelNotify &chan )
|
||||
cacChannelIO * cacServiceList::createChannelIO (
|
||||
const char *pName, cacChannelNotify &chan )
|
||||
{
|
||||
cacChannelIO *pChanIO = 0;
|
||||
|
||||
this->lock ();
|
||||
epicsAutoMutex locker ( this->mutex );
|
||||
tsDLIterBD < cacServiceIO > iter = this->services.firstIter ();
|
||||
while ( iter.valid () ) {
|
||||
pChanIO = iter->createChannelIO ( pName, cacCtx, chan );
|
||||
pChanIO = iter->createChannelIO ( pName, chan );
|
||||
if ( pChanIO ) {
|
||||
break;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
this->unlock ();
|
||||
|
||||
return pChanIO;
|
||||
}
|
||||
|
||||
void cacServiceList::show ( unsigned level ) const
|
||||
{
|
||||
this->lock ();
|
||||
epicsAutoMutex locker ( this->mutex );
|
||||
tsDLIterConstBD < cacServiceIO > iter = this->services.firstIter ();
|
||||
while ( iter.valid () ) {
|
||||
iter->show ( level );
|
||||
iter++;
|
||||
}
|
||||
this->unlock ();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,11 +36,13 @@ inline void comBuf::destroy ()
|
||||
|
||||
inline void * comBuf::operator new ( size_t size )
|
||||
{
|
||||
epicsAutoMutex locker ( comBuf::freeListMutex );
|
||||
return comBuf::freeList.allocate ( size );
|
||||
}
|
||||
|
||||
inline void comBuf::operator delete ( void *pCadaver, size_t size )
|
||||
{
|
||||
epicsAutoMutex locker ( comBuf::freeListMutex );
|
||||
comBuf::freeList.release ( pCadaver, size );
|
||||
}
|
||||
|
||||
@@ -116,7 +118,7 @@ inline unsigned comBuf::removeBytes ( unsigned nBytes )
|
||||
return nBytes;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::maxBytes ()
|
||||
inline unsigned comBuf::capacityBytes ()
|
||||
{
|
||||
return comBufSize;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "oldAccess.h"
|
||||
|
||||
tsFreeList < class getCallback, 1024 > getCallback::freeList;
|
||||
epicsMutex getCallback::freeListMutex;
|
||||
|
||||
getCallback::~getCallback ()
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "iocinf.h"
|
||||
|
||||
tsFreeList < hostNameCache, 16 > hostNameCache::freeList;
|
||||
epicsMutex hostNameCache::freeListMutex;
|
||||
|
||||
hostNameCache::hostNameCache ( const osiSockAddr &addr, ipAddrToAsciiEngine &engine ) :
|
||||
ipAddrToAsciiAsynchronous ( addr ),
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
|
||||
void * msgForMultiplyDefinedPV::operator new ( size_t size )
|
||||
{
|
||||
epicsAutoMutex locker ( msgForMultiplyDefinedPV::freeListMutex );
|
||||
return msgForMultiplyDefinedPV::freeList.allocate ( size );
|
||||
}
|
||||
|
||||
void msgForMultiplyDefinedPV::operator delete ( void *pCadaver, size_t size )
|
||||
{
|
||||
epicsAutoMutex locker ( msgForMultiplyDefinedPV::freeListMutex );
|
||||
msgForMultiplyDefinedPV::freeList.release ( pCadaver, size );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user