From 1dbf736ad2abbb769648dabc11c2f6fc09347bd5 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Mon, 2 Sep 2013 23:17:52 +0200 Subject: [PATCH] fixed version reporting (shows module version) now; fixed system configuration and startPVAServer user specified provider name(s) --- pvAccessApp/pva/pvaVersion.h | 7 ++++ .../remoteClient/clientContextImpl.cpp | 6 ++- pvAccessApp/server/responseHandlers.cpp | 38 ++++++++++++++++++- pvAccessApp/server/serverContext.cpp | 7 ++-- pvAccessApp/utils/configuration.cpp | 7 ++-- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/pvAccessApp/pva/pvaVersion.h b/pvAccessApp/pva/pvaVersion.h index 01c98da..f4cb47c 100644 --- a/pvAccessApp/pva/pvaVersion.h +++ b/pvAccessApp/pva/pvaVersion.h @@ -10,6 +10,13 @@ #include #include +// module version +// TODO to be generated, etc. +#define EPICS_PVA_MAJOR_VERSION 3 +#define EPICS_PVA_MINOR_VERSION 0 +#define EPICS_PVA_MAINTENANCE_VERSION 1 +#define EPICS_PVA_DEVELOPMENT_FLAG 0 + namespace epics { namespace pvAccess { diff --git a/pvAccessApp/remoteClient/clientContextImpl.cpp b/pvAccessApp/remoteClient/clientContextImpl.cpp index 7e45e1d..7ab13f8 100644 --- a/pvAccessApp/remoteClient/clientContextImpl.cpp +++ b/pvAccessApp/remoteClient/clientContextImpl.cpp @@ -3991,7 +3991,11 @@ namespace epics { m_addressList(""), m_autoAddressList(true), m_connectionTimeout(30.0f), m_beaconPeriod(15.0f), m_broadcastPort(PVA_BROADCAST_PORT), m_receiveBufferSize(MAX_TCP_RECV), m_namedLocker(), m_lastCID(0), m_lastIOID(0), - m_version("pvAccess Client", "cpp", 4, 3, 0, false), + m_version("pvAccess Client", "cpp", + EPICS_PVA_MAJOR_VERSION, + EPICS_PVA_MINOR_VERSION, + EPICS_PVA_MAINTENANCE_VERSION, + EPICS_PVA_DEVELOPMENT_FLAG), m_contextState(CONTEXT_NOT_INITIALIZED), m_configuration(new SystemConfigurationImpl()), m_flushStrategy(DELAYED) diff --git a/pvAccessApp/server/responseHandlers.cpp b/pvAccessApp/server/responseHandlers.cpp index 1e75912..87506ed 100644 --- a/pvAccessApp/server/responseHandlers.cpp +++ b/pvAccessApp/server/responseHandlers.cpp @@ -651,6 +651,11 @@ void ServerChannelGetRequesterImpl::getDone(const Status& status) void ServerChannelGetRequesterImpl::destroy() { + // keep a reference to ourselves as the owner + // could release its reference and we don't want to be + // destroyed prematurely + shared_pointer self(shared_from_this()); + { Lock guard(_mutex); _channel->unregisterRequest(_ioid); @@ -874,6 +879,11 @@ void ServerChannelPutRequesterImpl::unlock() void ServerChannelPutRequesterImpl::destroy() { + // keep a reference to ourselves as the owner + // could release its reference and we don't want to be + // destroyed prematurely + shared_pointer self(shared_from_this()); + { Lock guard(_mutex); _channel->unregisterRequest(_ioid); @@ -1097,6 +1107,11 @@ void ServerChannelPutGetRequesterImpl::unlock() void ServerChannelPutGetRequesterImpl::destroy() { + // keep a reference to ourselves as the owner + // could release its reference and we don't want to be + // destroyed prematurely + shared_pointer self(shared_from_this()); + { Lock guard(_mutex); _channel->unregisterRequest(_ioid); @@ -1317,6 +1332,11 @@ void ServerMonitorRequesterImpl::unlock() void ServerMonitorRequesterImpl::destroy() { + // keep a reference to ourselves as the owner + // could release its reference and we don't want to be + // destroyed prematurely + shared_pointer self(shared_from_this()); + { Lock guard(_mutex); _channel->unregisterRequest(_ioid); @@ -1550,6 +1570,11 @@ void ServerChannelArrayRequesterImpl::unlock() void ServerChannelArrayRequesterImpl::destroy() { + // keep a reference to ourselves as the owner + // could release its reference and we don't want to be + // destroyed prematurely + shared_pointer self(shared_from_this()); + { Lock guard(_mutex); _channel->unregisterRequest(_ioid); @@ -1766,6 +1791,11 @@ void ServerChannelProcessRequesterImpl::unlock() void ServerChannelProcessRequesterImpl::destroy() { + // keep a reference to ourselves as the owner + // could release its reference and we don't want to be + // destroyed prematurely + shared_pointer self(shared_from_this()); + { Lock guard(_mutex); _channel->unregisterRequest(_ioid); @@ -1880,7 +1910,8 @@ void ServerGetFieldRequesterImpl::send(ByteBuffer* buffer, TransportSendControl* { Lock guard(_mutex); _status.serialize(buffer, control); - control->cachedSerialize(_field, buffer); + if (_status.isSuccess()) + control->cachedSerialize(_field, buffer); } } @@ -2009,6 +2040,11 @@ void ServerChannelRPCRequesterImpl::unlock() void ServerChannelRPCRequesterImpl::destroy() { + // keep a reference to ourselves as the owner + // could release its reference and we don't want to be + // destroyed prematurely + shared_pointer self(shared_from_this()); + { Lock guard(_mutex); _channel->unregisterRequest(_ioid); diff --git a/pvAccessApp/server/serverContext.cpp b/pvAccessApp/server/serverContext.cpp index d74904b..ce63242 100644 --- a/pvAccessApp/server/serverContext.cpp +++ b/pvAccessApp/server/serverContext.cpp @@ -18,7 +18,8 @@ using std::tr1::static_pointer_cast; namespace epics { namespace pvAccess { const char* ServerContextImpl::StateNames[] = { "NOT_INITIALIZED", "INITIALIZED", "RUNNING", "SHUTDOWN", "DESTROYED"}; -const Version ServerContextImpl::VERSION("pvAccess Server", "cpp", 4, 3, 0, false); +const Version ServerContextImpl::VERSION("pvAccess Server", "cpp", + EPICS_PVA_MAJOR_VERSION, EPICS_PVA_MINOR_VERSION, EPICS_PVA_MAINTENANCE_VERSION, EPICS_PVA_DEVELOPMENT_FLAG); ServerContextImpl::ServerContextImpl(): _state(NOT_INITIALIZED), @@ -616,9 +617,9 @@ ServerContext::shared_pointer startPVAServer(String const & providerNames, int t ServerContextImpl::shared_pointer ctx = ServerContextImpl::create(); // do not override configuration - if (providerNames == PVACCESS_ALL_PROVIDERS && !ctx->isChannelProviderNamePreconfigured()) + if (!ctx->isChannelProviderNamePreconfigured()) ctx->setChannelProviderName(providerNames); - + ChannelAccess::shared_pointer channelAccess = getChannelAccess(); ctx->initialize(channelAccess); diff --git a/pvAccessApp/utils/configuration.cpp b/pvAccessApp/utils/configuration.cpp index ebb9cdf..32f1f3a 100644 --- a/pvAccessApp/utils/configuration.cpp +++ b/pvAccessApp/utils/configuration.cpp @@ -76,7 +76,6 @@ string Properties::getProperty(const string &key, const string &defaultValue) return string(propertiesIterator->second); } - _properties[key] = defaultValue; return defaultValue; } @@ -335,12 +334,14 @@ string SystemConfigurationImpl::getPropertyAsString(const string &name, const st { return _properties->getProperty(name, string(val)); } - return _properties->getProperty(name,defaultValue); + return _properties->getProperty(name, defaultValue); } bool SystemConfigurationImpl::hasProperty(const string &key) { - return _properties->hasProperty(key); + strncpy(_envParam.name,key.c_str(),key.length() + 1); + const char* val = envGetConfigParamPtr(&_envParam); + return (val != NULL) || _properties->hasProperty(key); } ConfigurationProviderImpl::ConfigurationProviderImpl()