fix 'pva' provider registration during static linking

Move 'pva' provider registration into registry singleton
construction to ensure that it is done.
This commit is contained in:
Michael Davidsaver
2018-01-31 11:43:39 -08:00
parent b05ec689d0
commit abce3faa86
2 changed files with 9 additions and 45 deletions

View File

@@ -9,6 +9,7 @@
#include <osiSock.h>
#include <epicsThread.h>
#include <epicsSignal.h>
#include <pv/lock.h>
#include <pv/noDefaultMethods.h>
@@ -18,6 +19,7 @@
#define epicsExportSharedSymbols
#include <pv/pvAccess.h>
#include <pv/clientContextImpl.h>
#include <pv/factory.h>
#include "pv/codec.h"
#include <pv/serverContextImpl.h>
@@ -161,7 +163,12 @@ epicsThreadOnceId providerRegOnce = EPICS_THREAD_ONCE_INIT;
void providerRegInit(void*)
{
epicsSignalInstallSigAlarmIgnore();
epicsSignalInstallSigPipeIgnore();
providerRegGbl = new providerRegGbl_t;
providerRegGbl->clients->add("pva", createClientProvider);
registerRefCounter("ServerContextImpl", &ServerContextImpl::num_instances);
registerRefCounter("ServerChannel", &ServerChannel::num_instances);
registerRefCounter("BlockingTCPTransportCodec", &detail::BlockingTCPTransportCodec::num_instances);

View File

@@ -6,60 +6,17 @@
#include <string>
#include <epicsSignal.h>
#include <epicsExit.h>
#include <pv/lock.h>
#define epicsExportSharedSymbols
#include <pv/logger.h>
#include <pv/clientFactory.h>
#include <pv/clientContextImpl.h>
using namespace epics::pvData;
using namespace epics::pvAccess;
static
void pva_factory_cleanup(void*)
{
try {
ChannelProviderRegistry::clients()->remove("pva");
} catch(std::exception& e) {
LOG(logLevelWarn, "Error when unregister \"pva\" factory");
}
}
void ClientFactory::start()
{
epicsSignalInstallSigAlarmIgnore();
epicsSignalInstallSigPipeIgnore();
if(ChannelProviderRegistry::clients()->add("pva", createClientProvider, false))
epicsAtExit(&pva_factory_cleanup, NULL);
// 'pva' registration in ChannelAccessFactory.cpp
}
void ClientFactory::stop()
{
// unregister now done with exit hook
}
// automatically register on load
namespace {
struct pvaloader
{
pvaloader() {
ClientFactory::start();
}
} pvaloaderinstance;
} // namespace
// perhaps useful during dynamic loading?
extern "C" {
void registerClientProvider_pva()
{
try {
ClientFactory::start();
} catch(std::exception& e){
std::cerr<<"Error loading pva: "<<e.what()<<"\n";
}
}
} // extern "C"
void ClientFactory::stop() {}