fixed race condition

This commit is contained in:
Jeff Hill
2001-09-25 00:13:20 +00:00
parent 0768bb9764
commit c7a82c3ce2
2 changed files with 12 additions and 13 deletions
+4 -11
View File
@@ -173,7 +173,7 @@ void dbServiceIO::callStateNotify ( struct dbAddr & addr,
if ( status ) {
notify.exception ( ECA_GETFAIL,
"db_get_field() completed unsuccessfuly",
type, count);
type, count );
}
else {
notify.current ( type, count, this->pEventCallbackCache );
@@ -186,8 +186,8 @@ extern "C" void cacAttachClientCtx ( void * pPrivate )
assert ( status == ECA_NORMAL );
}
dbEventSubscription dbServiceIO::subscribe ( struct dbAddr &addr, dbChannelIO &chan,
dbSubscriptionIO &subscr, unsigned mask, cacChannel::ioid *pId )
dbEventSubscription dbServiceIO::subscribe ( struct dbAddr & addr, dbChannelIO & chan,
dbSubscriptionIO & subscr, unsigned mask )
{
dbEventSubscription es;
int status;
@@ -220,19 +220,12 @@ dbEventSubscription dbServiceIO::subscribe ( struct dbAddr &addr, dbChannelIO &c
es = db_add_event ( this->ctx, &addr,
dbSubscriptionEventCallback, (void *) &subscr, mask );
if ( es ) {
db_post_single_event ( es );
}
else {
if ( ! es ) {
epicsAutoMutex locker ( this->mutex );
chan.dbServicePrivateListOfIO::eventq.remove ( subscr );
this->ioTable.remove ( subscr );
}
if ( pId ) {
*pId = subscr.getId ();
}
return es;
}
+8 -2
View File
@@ -36,14 +36,20 @@ epicsMutex dbSubscriptionIO::freeListMutex;
dbSubscriptionIO::dbSubscriptionIO ( dbServiceIO &serviceIO, dbChannelIO &chanIO,
dbAddr &addr, cacStateNotify &notifyIn,
unsigned typeIn, unsigned long countIn, unsigned maskIn,
cacChannel::ioid * pId ) :
cacChannel::ioid * pId ) :
notify ( notifyIn ), chan ( chanIO ), es ( 0 ),
type ( typeIn ), count ( countIn ), id ( 0u )
{
this->es = serviceIO.subscribe ( addr, chanIO, *this, maskIn, pId );
this->es = serviceIO.subscribe ( addr, chanIO, *this, maskIn );
if ( ! this->es ) {
throw std::bad_alloc ();
}
if ( pId ) {
*pId = this->getId ();
}
db_post_single_event ( this->es );
}
dbSubscriptionIO::~dbSubscriptionIO ()