From ae899e981811eec7ad4ee2c7bf354174cf7dfeaf Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Wed, 3 Jan 2007 18:08:31 +0000 Subject: Bug 1327 - allow getClientProxy to return nil proxy --- cpp/src/Ice/RouterInfo.cpp | 99 +++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 59 deletions(-) (limited to 'cpp/src/Ice/RouterInfo.cpp') 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 #include // For ice_connection()->timeout(). #include +#include 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 +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 +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 -- cgit v1.2.3