pvalink: defer opening links until IOC running

This commit is contained in:
Michael Davidsaver
2018-05-28 07:49:59 -07:00
parent ff67302347
commit b3ffc49f71
4 changed files with 17 additions and 0 deletions

View File

@ -115,6 +115,18 @@ void initPVALink(initHookState state)
// after epicsExit(exitDatabase)
// so hook registered here will be run before iocShutdown()
epicsAtExit(stopPVAPool, NULL);
Guard G(pvaGlobal->lock);
pvaGlobal->running = true;
for(pvaGlobal_t::channels_t::iterator it(pvaGlobal->channels.begin()), end(pvaGlobal->channels.end());
it != end; ++it)
{
std::tr1::shared_ptr<pvaLinkChannel> chan(it->second.lock());
if(!chan) continue;
chan->open();
}
}
}

View File

@ -101,6 +101,8 @@ struct pvaGlobal_t {
pvd::Mutex lock;
bool running; // set after dbEvent is initialized and safe to use
// a tuple of channel name and printed pvRequest (or Monitor)
typedef std::pair<std::string, std::string> channels_key_t;
// pvaLinkChannel dtor prunes dead entires

View File

@ -20,6 +20,7 @@ pvaGlobal_t::pvaGlobal_t()
,provider_remote("pva")
,create(pvd::getPVDataCreate())
,queue("PVAL")
,running(false)
{
// worker should be above PVA worker priority?
queue.start(std::max(1, pvaLinkNWorkers), epicsThreadPriorityMedium);

View File

@ -76,6 +76,8 @@ void pvaOpenLink(DBLINK *plink)
pvaGlobal->channels.insert(std::make_pair(key, chan));
doOpen = true;
}
doOpen &= pvaGlobal->running; // if not running, then open from initHook
}
if(doOpen) {