diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/IceDiscovery/PluginI.cpp | 9 | ||||
-rw-r--r-- | cpp/src/IceDiscovery/PluginI.h | 1 | ||||
-rw-r--r-- | cpp/src/IceLocatorDiscovery/PluginI.cpp | 10 |
3 files changed, 16 insertions, 4 deletions
diff --git a/cpp/src/IceDiscovery/PluginI.cpp b/cpp/src/IceDiscovery/PluginI.cpp index 37992bdab35..1a76f34ff06 100644 --- a/cpp/src/IceDiscovery/PluginI.cpp +++ b/cpp/src/IceDiscovery/PluginI.cpp @@ -148,7 +148,8 @@ PluginI::initialize() // Ice::ObjectPrxPtr loc = _locatorAdapter->addWithUUID(ICE_MAKE_SHARED(LocatorI, _lookup, locatorRegistryPrx)); _defaultLocator = _communicator->getDefaultLocator(); - _communicator->setDefaultLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, loc)); + _locator = ICE_UNCHECKED_CAST(Ice::LocatorPrx, loc); + _communicator->setDefaultLocator(_locator); _multicastAdapter->activate(); _replyAdapter->activate(); @@ -162,5 +163,9 @@ PluginI::destroy() _replyAdapter->destroy(); _locatorAdapter->destroy(); _lookup->destroy(); - _communicator->setDefaultLocator(_defaultLocator); + // Restore original default locator proxy, if the user didn't change it in the meantime. + if(_communicator->getDefaultLocator() == _locator) + { + _communicator->setDefaultLocator(_defaultLocator); + } } diff --git a/cpp/src/IceDiscovery/PluginI.h b/cpp/src/IceDiscovery/PluginI.h index e8503667b1b..cd565b637e5 100644 --- a/cpp/src/IceDiscovery/PluginI.h +++ b/cpp/src/IceDiscovery/PluginI.h @@ -32,6 +32,7 @@ private: Ice::ObjectAdapterPtr _replyAdapter; Ice::ObjectAdapterPtr _locatorAdapter; LookupIPtr _lookup; + Ice::LocatorPrxPtr _locator; Ice::LocatorPrxPtr _defaultLocator; }; diff --git a/cpp/src/IceLocatorDiscovery/PluginI.cpp b/cpp/src/IceLocatorDiscovery/PluginI.cpp index 34c23efc01b..7a32c20a844 100644 --- a/cpp/src/IceLocatorDiscovery/PluginI.cpp +++ b/cpp/src/IceLocatorDiscovery/PluginI.cpp @@ -225,6 +225,7 @@ private: Ice::ObjectAdapterPtr _locatorAdapter; Ice::ObjectAdapterPtr _replyAdapter; LocatorIPtr _locator; + Ice::LocatorPrxPtr _locatorPrx; Ice::LocatorPrxPtr _defaultLocator; }; @@ -334,7 +335,8 @@ PluginI::initialize() _locator = ICE_MAKE_SHARED(LocatorI, _name, ICE_UNCHECKED_CAST(LookupPrx, lookupPrx), properties, instanceName, voidLocator); _defaultLocator = _communicator->getDefaultLocator(); - _communicator->setDefaultLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, _locatorAdapter->add(_locator, id))); + _locatorPrx = ICE_UNCHECKED_CAST(Ice::LocatorPrx, _locatorAdapter->add(_locator, id)); + _communicator->setDefaultLocator(_locatorPrx); Ice::ObjectPrxPtr lookupReply = _replyAdapter->addWithUUID(ICE_MAKE_SHARED(LookupReplyI, _locator))->ice_datagram(); _locator->setLookupReply(ICE_UNCHECKED_CAST(LookupReplyPrx, lookupReply)); @@ -354,7 +356,11 @@ PluginI::destroy() { _replyAdapter->destroy(); _locatorAdapter->destroy(); - _communicator->setDefaultLocator(_defaultLocator); + // Restore original default locator proxy, if the user didn't change it in the meantime + if(_communicator->getDefaultLocator() == _locatorPrx) + { + _communicator->setDefaultLocator(_defaultLocator); + } } void |