summaryrefslogtreecommitdiff
path: root/cpp/src/IcePack/ServerRegistryI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IcePack/ServerRegistryI.cpp')
-rw-r--r--cpp/src/IcePack/ServerRegistryI.cpp48
1 files changed, 32 insertions, 16 deletions
diff --git a/cpp/src/IcePack/ServerRegistryI.cpp b/cpp/src/IcePack/ServerRegistryI.cpp
index 42f637841dd..8f06a40fde9 100644
--- a/cpp/src/IcePack/ServerRegistryI.cpp
+++ b/cpp/src/IcePack/ServerRegistryI.cpp
@@ -34,35 +34,51 @@ void
IcePack::ServerRegistryI::add(const string& name,
const ServerPrx& server,
const ServerDescriptorPtr& descriptor,
- const Ice::Current&)
+ const Ice::Current& current)
{
- Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
- StringObjectProxyDict dict(connection, _dbName);
- StringServerDescriptorDict dictDescriptor(connection, _dbDescriptorName);
-
- StringObjectProxyDict::iterator p = dict.find(name);
- if(p != dict.end())
+ while(true)
{
+ ServerPrx oldServer;
try
{
- p->second->ice_ping();
+ oldServer = findByName(name, current);
+ oldServer->ice_ping();
throw ServerExistsException();
}
+ catch(const ServerNotExistException&)
+ {
+ }
catch(const Ice::ObjectNotExistException&)
{
}
catch(const Ice::LocalException&)
{
+ throw ServerExistsException();
+ }
+
+ Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
+ StringObjectProxyDict dict(connection, _dbName);
+ StringServerDescriptorDict dictDescriptor(connection, _dbDescriptorName);
+
+ StringObjectProxyDict::iterator p = dict.find(name);
+ if(p != dict.end())
+ {
+ if(oldServer && oldServer != p->second)
+ {
+ continue;
+ }
}
- }
-
- dict.put(pair<const string, const Ice::ObjectPrx>(name, server));
- dictDescriptor.put(pair<const string, const ServerDescriptorPtr>(name, descriptor));
- if(_traceLevels->serverRegistry > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverRegistryCat);
- out << "added server `" << name << "'";
+ dict.put(pair<const string, const Ice::ObjectPrx>(name, server));
+ dictDescriptor.put(pair<const string, const ServerDescriptorPtr>(name, descriptor));
+
+ if(_traceLevels->serverRegistry > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverRegistryCat);
+ out << "added server `" << name << "'";
+ }
+
+ break;
}
}