cleanup phase I
This commit is contained in:
@@ -4,7 +4,10 @@
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include <pv/clientFactory.h>
|
||||
#include <pv/clientContextImpl.h>
|
||||
#include <pv/lock.h>
|
||||
#include <pv/logger.h>
|
||||
|
||||
#include <epicsSignal.h>
|
||||
@@ -12,23 +15,22 @@
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
|
||||
Mutex ClientFactory::m_mutex;
|
||||
ClientContextImpl::shared_pointer ClientFactory::m_context;
|
||||
// TODO global static variable (de/initialization order not guaranteed)
|
||||
static Mutex m_mutex;
|
||||
static ClientContextImpl::shared_pointer m_context;
|
||||
|
||||
void ClientFactory::start()
|
||||
{
|
||||
epicsSignalInstallSigAlarmIgnore ();
|
||||
epicsSignalInstallSigPipeIgnore ();
|
||||
epicsSignalInstallSigAlarmIgnore();
|
||||
epicsSignalInstallSigPipeIgnore();
|
||||
|
||||
Lock guard(m_mutex);
|
||||
|
||||
if (m_context.get()) return;
|
||||
|
||||
try {
|
||||
m_context = createClientContextImpl();
|
||||
m_context->initialize();
|
||||
ChannelProvider::shared_pointer provider = m_context->getProvider();
|
||||
registerChannelProvider(provider);
|
||||
registerChannelProvider(m_context->getProvider());
|
||||
} catch (std::exception &e) {
|
||||
LOG(logLevelError, "Unhandled exception caught at %s:%d: %s", __FILE__, __LINE__, e.what());
|
||||
} catch (...) {
|
||||
@@ -39,11 +41,9 @@ void ClientFactory::start()
|
||||
void ClientFactory::stop()
|
||||
{
|
||||
Lock guard(m_mutex);
|
||||
|
||||
if (!m_context.get()) return;
|
||||
|
||||
ChannelProvider::shared_pointer provider = m_context->getProvider();
|
||||
unregisterChannelProvider(provider);
|
||||
unregisterChannelProvider(m_context->getProvider());
|
||||
|
||||
m_context->dispose();
|
||||
m_context.reset();
|
||||
|
||||
Reference in New Issue
Block a user