From 9cbc8fdea6ad8874253078d8f15017a4a4f52d63 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 7 Jun 2017 14:36:15 +0200 Subject: [PATCH] handle multiple ClientFactory::start() --- src/pva/clientFactory.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/pva/clientFactory.cpp b/src/pva/clientFactory.cpp index 6ffdbed..2f43a04 100644 --- a/src/pva/clientFactory.cpp +++ b/src/pva/clientFactory.cpp @@ -7,7 +7,7 @@ #include #include - +#include #include #define epicsExportSharedSymbols @@ -18,15 +18,26 @@ using namespace epics::pvData; using namespace epics::pvAccess; +static +void pva_factory_cleanup(void*) +{ + try { + getChannelProviderRegistry()->remove("pva"); + } catch(std::exception& e) { + LOG(logLevelWarn, "Error when unregister \"pva\" factory"); + } +} + void ClientFactory::start() { epicsSignalInstallSigAlarmIgnore(); epicsSignalInstallSigPipeIgnore(); - getChannelProviderRegistry()->add("pva", createClientProvider, false); + if(getChannelProviderRegistry()->add("pva", createClientProvider, false)) + epicsAtExit(&pva_factory_cleanup, NULL); } void ClientFactory::stop() { - getChannelProviderRegistry()->remove("pva"); + // unregister now done with exit hook }