summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/RouterInfo.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2007-01-03 18:08:31 +0000
committerDwayne Boone <dwayne@zeroc.com>2007-01-03 18:08:31 +0000
commitae899e981811eec7ad4ee2c7bf354174cf7dfeaf (patch)
tree8606155063f77cf50d0d28e335c544bd776b603a /cpp/src/Ice/RouterInfo.cpp
parentAdded -bind_at_load, without this we get various crashes in the linker (diff)
downloadice-ae899e981811eec7ad4ee2c7bf354174cf7dfeaf.tar.bz2
ice-ae899e981811eec7ad4ee2c7bf354174cf7dfeaf.tar.xz
ice-ae899e981811eec7ad4ee2c7bf354174cf7dfeaf.zip
Bug 1327 - allow getClientProxy to return nil proxy
Diffstat (limited to 'cpp/src/Ice/RouterInfo.cpp')
-rw-r--r--cpp/src/Ice/RouterInfo.cpp99
1 files changed, 40 insertions, 59 deletions
diff --git a/cpp/src/Ice/RouterInfo.cpp b/cpp/src/Ice/RouterInfo.cpp
index 9347ff82c09..33e59a2f218 100644
--- a/cpp/src/Ice/RouterInfo.cpp
+++ b/cpp/src/Ice/RouterInfo.cpp
@@ -12,6 +12,7 @@
#include <Ice/LocalException.h>
#include <Ice/Connection.h> // For ice_connection()->timeout().
#include <Ice/Functional.h>
+#include <Ice/Reference.h>
using namespace std;
using namespace Ice;
@@ -120,8 +121,8 @@ IceInternal::RouterInfo::destroy()
{
IceUtil::Mutex::Lock sync(*this);
- _clientProxy = 0;
- _serverProxy = 0;
+ _clientEndpoints.clear();
+ _serverEndpoints.clear();
_adapter = 0;
_identities.clear();
}
@@ -153,85 +154,65 @@ IceInternal::RouterInfo::getRouter() const
return _router;
}
-ObjectPrx
-IceInternal::RouterInfo::getClientProxy()
+vector<EndpointIPtr>
+IceInternal::RouterInfo::getClientEndpoints()
{
IceUtil::Mutex::Lock sync(*this);
- if(!_clientProxy) // Lazy initialization.
+ if(_clientEndpoints.size() == 0) // Lazy initialization.
{
- _clientProxy = _router->getClientProxy();
- if(!_clientProxy)
+ ObjectPrx clientProxy = _router->getClientProxy();
+ if(!clientProxy)
{
- throw NoEndpointException(__FILE__, __LINE__);
- }
-
- _clientProxy = _clientProxy->ice_router(0); // The client proxy cannot be routed.
-
- //
- // In order to avoid creating a new connection to the router,
- // we must use the same timeout as the already existing
- // connection.
- //
- try
- {
- _clientProxy = _clientProxy->ice_timeout(_router->ice_getConnection()->timeout());
+ //
+ // If getClientProxy() return nil, use router endpoints.
+ //
+ _clientEndpoints = _router->__reference()->getEndpoints();
}
- catch(const Ice::CollocationOptimizationException&)
+ else
{
- // Ignore - collocated router
+ clientProxy = clientProxy->ice_router(0); // The client proxy cannot be routed.
+
+ //
+ // In order to avoid creating a new connection to the router,
+ // we must use the same timeout as the already existing
+ // connection.
+ //
+ try
+ {
+ clientProxy = clientProxy->ice_timeout(_router->ice_getConnection()->timeout());
+ }
+ catch(const Ice::CollocationOptimizationException&)
+ {
+ // Ignore - collocated router
+ }
+
+ _clientEndpoints = clientProxy->__reference()->getEndpoints();
}
}
- return _clientProxy;
+ return _clientEndpoints;
}
-void
-IceInternal::RouterInfo::setClientProxy(const ObjectPrx& clientProxy)
-{
- IceUtil::Mutex::Lock sync(*this);
-
- _clientProxy = clientProxy->ice_router(0); // The client proxy cannot be routed.
-
- //
- // In order to avoid creating a new connection to the router, we
- // must use the same timeout as the already existing connection.
- //
- try
- {
- _clientProxy = _clientProxy->ice_timeout(_router->ice_getConnection()->timeout());
- }
- catch(const Ice::CollocationOptimizationException&)
- {
- // Ignore - collocated router
- }
-}
-
-ObjectPrx
-IceInternal::RouterInfo::getServerProxy()
+vector<EndpointIPtr>
+IceInternal::RouterInfo::getServerEndpoints()
{
IceUtil::Mutex::Lock sync(*this);
- if(!_serverProxy) // Lazy initialization.
+ if(_serverEndpoints.size() == 0) // Lazy initialization.
{
- _serverProxy = _router->getServerProxy();
- if(!_serverProxy)
+ ObjectPrx serverProxy = _router->getServerProxy();
+ if(!serverProxy)
{
throw NoEndpointException(__FILE__, __LINE__);
}
- _serverProxy = _serverProxy->ice_router(0); // The server proxy cannot be routed.
+ serverProxy = serverProxy->ice_router(0); // The server proxy cannot be routed.
+
+ _serverEndpoints = serverProxy->__reference()->getEndpoints();
}
- return _serverProxy;
-}
-
-void
-IceInternal::RouterInfo::setServerProxy(const ObjectPrx& serverProxy)
-{
- IceUtil::Mutex::Lock sync(*this);
-
- _serverProxy = serverProxy->ice_router(0); // The server proxy cannot be routed.
+ return _serverEndpoints;
}
void