diff --git a/src/db/dbServiceIO.cpp b/src/db/dbServiceIO.cpp index 28d664bc5..31e475d54 100644 --- a/src/db/dbServiceIO.cpp +++ b/src/db/dbServiceIO.cpp @@ -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; } diff --git a/src/db/dbSubscriptionIO.cpp b/src/db/dbSubscriptionIO.cpp index 822927f98..f8f181660 100644 --- a/src/db/dbSubscriptionIO.cpp +++ b/src/db/dbSubscriptionIO.cpp @@ -36,14 +36,20 @@ epicsMutex dbSubscriptionIO::freeListMutex; dbSubscriptionIO::dbSubscriptionIO ( dbServiceIO &serviceIO, dbChannelIO &chanIO, dbAddr &addr, cacStateNotify ¬ifyIn, 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 ()