diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 167 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/EndpointI.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/IPEndpointI.cpp | 53 | ||||
-rw-r--r-- | cpp/src/Ice/IPEndpointI.h | 3 | ||||
-rw-r--r-- | cpp/src/Ice/OpaqueEndpointI.cpp | 7 | ||||
-rw-r--r-- | cpp/src/Ice/OpaqueEndpointI.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/ProtocolInstance.cpp | 7 | ||||
-rw-r--r-- | cpp/src/Ice/ProtocolInstance.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 227 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/WSEndpoint.cpp | 11 | ||||
-rw-r--r-- | cpp/src/Ice/WSEndpoint.h | 1 |
13 files changed, 39 insertions, 445 deletions
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index db378242b6a..0fa44c14a95 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -157,173 +157,6 @@ IceInternal::OutgoingConnectionFactory::waitUntilFinished() } } -ConnectionIPtr -IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpts, bool hasMore, - Ice::EndpointSelectionType selType, bool& compress) -{ - assert(!endpts.empty()); - - // - // Apply the overrides. - // - vector<EndpointIPtr> endpoints = applyOverrides(endpts); - - // - // Try to find a connection to one of the given endpoints. - // - Ice::ConnectionIPtr connection = findConnection(endpoints, compress); - if(connection) - { - return connection; - } - - IceUtil::UniquePtr<Ice::LocalException> exception; - - // - // If we didn't find a connection with the endpoints, we create the connectors - // for the endpoints. - // - vector<ConnectorInfo> connectors; - for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p) - { - // - // Create connectors for the endpoint. - // - try - { - vector<ConnectorPtr> cons = (*p)->connectors(selType); - assert(!cons.empty()); - for(vector<ConnectorPtr>::const_iterator r = cons.begin(); r != cons.end(); ++r) - { - assert(*r); - connectors.push_back(ConnectorInfo(*r, *p)); - } - } - catch(const Ice::LocalException& ex) - { - exception.reset(ex.ice_clone()); - handleException(ex, hasMore || p != endpoints.end() - 1); - } - } - - if(connectors.empty()) - { - assert(exception.get()); - exception->ice_throw(); - } - - // - // Try to get a connection to one of the connectors. A null result indicates that no - // connection was found and that we should try to establish the connection (and that - // the connectors were added to _pending to prevent other threads from establishing - // the connection). - // - connection = getConnection(connectors, 0, compress); - if(connection) - { - return connection; - } - - // - // Try to establish the connection to the connectors. - // - DefaultsAndOverridesPtr defaultsAndOverrides = _instance->defaultsAndOverrides(); - const CommunicatorObserverPtr& obsv = _instance->initializationData().observer; - vector<ConnectorInfo>::const_iterator q; - for(q = connectors.begin(); q != connectors.end(); ++q) - { - ObserverPtr observer; - if(obsv) - { - observer = obsv->getConnectionEstablishmentObserver(q->endpoint, q->connector->toString()); - if(observer) - { - observer->attach(); - } - } - - try - { - if(_instance->traceLevels()->network >= 2) - { - Trace out(_instance->initializationData().logger, _instance->traceLevels()->networkCat); - out << "trying to establish " << q->endpoint->protocol() << " connection to " - << q->connector->toString(); - } - connection = createConnection(q->connector->connect(), *q); - connection->start(0); - - if(observer) - { - observer->detach(); - } - - if(defaultsAndOverrides->overrideCompress) - { - compress = defaultsAndOverrides->overrideCompressValue; - } - else - { - compress = q->endpoint->compress(); - } - - connection->activate(); - break; - } - catch(const Ice::CommunicatorDestroyedException& ex) - { - if(observer) - { - observer->failed(ex.ice_name()); - observer->detach(); - } - exception.reset(ex.ice_clone()); - handleConnectionException(*exception.get(), hasMore || q != connectors.end() - 1); - connection = 0; - break; // No need to continue - } - catch(const Ice::LocalException& ex) - { - if(_instance->traceLevels()->network >= 2) - { - Trace out(_instance->initializationData().logger, _instance->traceLevels()->networkCat); - out << "failed to establish " << q->endpoint->protocol() << " connection to " - << q->connector->toString() << "\n" << ex; - } - - if(observer) - { - observer->failed(ex.ice_name()); - observer->detach(); - } - exception.reset(ex.ice_clone()); - handleConnectionException(*exception.get(), hasMore || q != connectors.end() - 1); - connection = 0; - } - } - - // - // Finish creating the connection (this removes the connectors from the _pending - // list and notifies any waiting threads). - // - if(connection) - { - finishGetConnection(connectors, *q, connection, 0); - } - else - { - finishGetConnection(connectors, *exception.get(), 0); - } - - if(!connection) - { - assert(exception.get()); - exception->ice_throw(); - } - - return connection; -} - void IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpts, bool hasMore, Ice::EndpointSelectionType selType, diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h index 1026027d87e..9370bb45a23 100644 --- a/cpp/src/Ice/ConnectionFactory.h +++ b/cpp/src/Ice/ConnectionFactory.h @@ -62,7 +62,6 @@ public: void waitUntilFinished(); - Ice::ConnectionIPtr create(const std::vector<EndpointIPtr>&, bool, Ice::EndpointSelectionType, bool&); void create(const std::vector<EndpointIPtr>&, bool, Ice::EndpointSelectionType, const CreateConnectionCallbackPtr&); void setRouterInfo(const RouterInfoPtr&); diff --git a/cpp/src/Ice/EndpointI.h b/cpp/src/Ice/EndpointI.h index 8806e0790ea..4088597db3f 100644 --- a/cpp/src/Ice/EndpointI.h +++ b/cpp/src/Ice/EndpointI.h @@ -109,7 +109,6 @@ public: // returning connectors sorted according to the endpoint selection // type. // - virtual std::vector<ConnectorPtr> connectors(Ice::EndpointSelectionType) const = 0; virtual void connectors_async(Ice::EndpointSelectionType, const EndpointI_connectorsPtr&) const = 0; // diff --git a/cpp/src/Ice/IPEndpointI.cpp b/cpp/src/Ice/IPEndpointI.cpp index b8df1f4da07..306f975c879 100644 --- a/cpp/src/Ice/IPEndpointI.cpp +++ b/cpp/src/Ice/IPEndpointI.cpp @@ -123,12 +123,6 @@ IceInternal::IPEndpointI::connectionId(const string& connectionId) const } } -vector<ConnectorPtr> -IceInternal::IPEndpointI::connectors(Ice::EndpointSelectionType selType) const -{ - return _instance->resolve(_host, _port, selType, const_cast<IPEndpointI*>(this)); -} - const std::string& IceInternal::IPEndpointI::host() const { @@ -531,53 +525,6 @@ IceInternal::EndpointHostResolver::EndpointHostResolver(const InstancePtr& insta __setNoDelete(false); } -vector<ConnectorPtr> -IceInternal::EndpointHostResolver::resolve(const string& host, int port, Ice::EndpointSelectionType selType, - const IPEndpointIPtr& endpoint) -{ - // - // Try to get the addresses without DNS lookup. If this doesn't - // work, we retry with DNS lookup (and observer). - // - NetworkProxyPtr networkProxy = _instance->networkProxy(); - if(!networkProxy) - { - vector<Address> addrs = getAddresses(host, port, _protocol, selType, _preferIPv6, false); - if(!addrs.empty()) - { - return endpoint->connectors(addrs, 0); - } - } - - ObserverHelperT<> observer; - const CommunicatorObserverPtr& obsv = _instance->initializationData().observer; - if(obsv) - { - observer.attach(obsv->getEndpointLookupObserver(endpoint)); - } - - vector<ConnectorPtr> connectors; - try - { - ProtocolSupport protocol = _protocol; - if(networkProxy) - { - networkProxy = networkProxy->resolveHost(_protocol); - if(networkProxy) - { - protocol = networkProxy->getProtocolSupport(); - } - } - connectors = endpoint->connectors(getAddresses(host, port, protocol, selType, _preferIPv6, true), networkProxy); - } - catch(const Ice::LocalException& ex) - { - observer.failed(ex.ice_name()); - throw; - } - return connectors; -} - void IceInternal::EndpointHostResolver::resolve(const string& host, int port, Ice::EndpointSelectionType selType, const IPEndpointIPtr& endpoint, const EndpointI_connectorsPtr& callback) diff --git a/cpp/src/Ice/IPEndpointI.h b/cpp/src/Ice/IPEndpointI.h index f63a137f3b3..a4b24fc6d69 100644 --- a/cpp/src/Ice/IPEndpointI.h +++ b/cpp/src/Ice/IPEndpointI.h @@ -55,7 +55,6 @@ public: virtual const std::string& connectionId() const; virtual EndpointIPtr connectionId(const ::std::string&) const; - virtual std::vector<ConnectorPtr> connectors(Ice::EndpointSelectionType) const; virtual void connectors_async(Ice::EndpointSelectionType, const EndpointI_connectorsPtr&) const; virtual std::vector<EndpointIPtr> expand() const; virtual bool equivalent(const EndpointIPtr&) const; @@ -73,7 +72,6 @@ public: virtual void hashInit(Ice::Int&) const; virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const; - using EndpointI::connectors; using EndpointI::connectionId; virtual void initWithOptions(std::vector<std::string>&, bool); @@ -113,7 +111,6 @@ public: EndpointHostResolver(const InstancePtr&); - std::vector<ConnectorPtr> resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&); void resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&, const EndpointI_connectorsPtr&); void destroy(); diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp index ff495474d3c..da117e01172 100644 --- a/cpp/src/Ice/OpaqueEndpointI.cpp +++ b/cpp/src/Ice/OpaqueEndpointI.cpp @@ -175,13 +175,6 @@ IceInternal::OpaqueEndpointI::transceiver() const return 0; } -vector<ConnectorPtr> -IceInternal::OpaqueEndpointI::connectors(Ice::EndpointSelectionType) const -{ - vector<ConnectorPtr> ret; - return ret; -} - void IceInternal::OpaqueEndpointI::connectors_async(Ice::EndpointSelectionType, const EndpointI_connectorsPtr& cb) const { diff --git a/cpp/src/Ice/OpaqueEndpointI.h b/cpp/src/Ice/OpaqueEndpointI.h index 03fe3066f06..5d3da611f98 100644 --- a/cpp/src/Ice/OpaqueEndpointI.h +++ b/cpp/src/Ice/OpaqueEndpointI.h @@ -38,7 +38,6 @@ public: virtual bool secure() const; virtual TransceiverPtr transceiver() const; - virtual std::vector<ConnectorPtr> connectors(Ice::EndpointSelectionType) const; virtual void connectors_async(Ice::EndpointSelectionType, const EndpointI_connectorsPtr&) const; virtual AcceptorPtr acceptor(const std::string&) const; virtual std::vector<EndpointIPtr> expand() const; diff --git a/cpp/src/Ice/ProtocolInstance.cpp b/cpp/src/Ice/ProtocolInstance.cpp index 2c27bb2c0c2..530a6b8a230 100644 --- a/cpp/src/Ice/ProtocolInstance.cpp +++ b/cpp/src/Ice/ProtocolInstance.cpp @@ -89,13 +89,6 @@ IceInternal::ProtocolInstance::messageSizeMax() const return _instance->messageSizeMax(); } -vector<ConnectorPtr> -IceInternal::ProtocolInstance::resolve(const string& host, int port, EndpointSelectionType type, - const IPEndpointIPtr& endpt) const -{ - return _instance->endpointHostResolver()->resolve(host, port, type, endpt); -} - void IceInternal::ProtocolInstance::resolve(const string& host, int port, EndpointSelectionType type, const IPEndpointIPtr& endpt, const EndpointI_connectorsPtr& cb) const diff --git a/cpp/src/Ice/ProtocolInstance.h b/cpp/src/Ice/ProtocolInstance.h index 60ce51426f2..ecb9601626f 100644 --- a/cpp/src/Ice/ProtocolInstance.h +++ b/cpp/src/Ice/ProtocolInstance.h @@ -68,7 +68,6 @@ public: size_t messageSizeMax() const; int defaultTimeout() const; - std::vector<ConnectorPtr> resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&) const; void resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&, const EndpointI_connectorsPtr&) const; diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index c4e11579114..f6110157721 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -750,11 +750,13 @@ IceInternal::FixedReference::toProperty(const string&) const return PropertyDict(); // To keep the compiler from complaining. } -ConnectionIPtr -IceInternal::FixedReference::getConnection(bool& compress) const +void +IceInternal::FixedReference::getConnection(const GetConnectionCallbackPtr& callback) const { - switch(getMode()) + try { + switch(getMode()) + { case Reference::ModeTwoway: case Reference::ModeOneway: case Reference::ModeBatchOneway: @@ -775,52 +777,43 @@ IceInternal::FixedReference::getConnection(bool& compress) const } break; } - } - - // - // If a secure connection is requested or secure overrides is set, - // check if the connection is secure. - // - bool secure; - DefaultsAndOverridesPtr defaultsAndOverrides = getInstance()->defaultsAndOverrides(); - if(defaultsAndOverrides->overrideSecure) - { - secure = defaultsAndOverrides->overrideSecureValue; - } - else - { - secure = getSecure(); - } - if(secure && !_fixedConnection->endpoint()->secure()) - { - throw NoEndpointException(__FILE__, __LINE__, ""); - } - - _fixedConnection->throwException(); // Throw in case our connection is already destroyed. + } - if(defaultsAndOverrides->overrideCompress) - { - compress = defaultsAndOverrides->overrideCompressValue; - } - else if(_overrideCompress) - { - compress = _compress; - } - else - { - compress = _fixedConnection->endpoint()->compress(); - } - return _fixedConnection; -} + // + // If a secure connection is requested or secure overrides is set, + // check if the connection is secure. + // + bool secure; + DefaultsAndOverridesPtr defaultsAndOverrides = getInstance()->defaultsAndOverrides(); + if(defaultsAndOverrides->overrideSecure) + { + secure = defaultsAndOverrides->overrideSecureValue; + } + else + { + secure = getSecure(); + } + if(secure && !_fixedConnection->endpoint()->secure()) + { + throw NoEndpointException(__FILE__, __LINE__, ""); + } -void -IceInternal::FixedReference::getConnection(const GetConnectionCallbackPtr& callback) const -{ - try - { + _fixedConnection->throwException(); // Throw in case our connection is already destroyed. + bool compress; - ConnectionIPtr connection = getConnection(compress); - callback->setConnection(connection, compress); + if(defaultsAndOverrides->overrideCompress) + { + compress = defaultsAndOverrides->overrideCompressValue; + } + else if(_overrideCompress) + { + compress = _compress; + } + else + { + compress = _fixedConnection->endpoint()->compress(); + } + callback->setConnection(_fixedConnection, compress); } catch(const Ice::LocalException& ex) { @@ -1508,79 +1501,6 @@ IceInternal::RoutableReference::clone() const return new RoutableReference(*this); } -ConnectionIPtr -IceInternal::RoutableReference::getConnection(bool& comp) const -{ - if(_routerInfo) - { - // - // If we route, we send everything to the router's client - // proxy endpoints. - // - vector<EndpointIPtr> endpts = _routerInfo->getClientEndpoints(); - if(!endpts.empty()) - { - applyOverrides(endpts); - return createConnection(endpts, comp); - } - } - - if(!_endpoints.empty()) - { - return createConnection(_endpoints, comp); - } - - while(true) - { - bool cached = false; - vector<EndpointIPtr> endpts; - if(_locatorInfo) - { - endpts = _locatorInfo->getEndpoints(const_cast<RoutableReference*>(this), _locatorCacheTimeout, cached); - applyOverrides(endpts); - } - - if(endpts.empty()) - { - throw Ice::NoEndpointException(__FILE__, __LINE__, toString()); - } - - try - { - return createConnection(endpts, comp); - } - catch(const NoEndpointException&) - { - throw; // No need to retry if there's no endpoints. - } - catch(const LocalException& ex) - { - assert(_locatorInfo); - _locatorInfo->clearCache(const_cast<RoutableReference*>(this)); - - if(cached) - { - // COMPILERFIX: Braces needed to prevent BCB from causing TraceLevels refCount from - // being decremented twice when loop continues. - { - TraceLevelsPtr traceLevels = getInstance()->traceLevels(); - if(traceLevels->retry >= 2) - { - Trace out(getInstance()->initializationData().logger, traceLevels->retryCat); - out << "connection to cached endpoints failed\n" - << "removing endpoints from cache and trying one more time\n" << ex; - } - } - continue; - } - throw; - } - } - - assert(false); - return 0; -} - void IceInternal::RoutableReference::getConnection(const GetConnectionCallbackPtr& callback) const { @@ -1742,75 +1662,6 @@ IceInternal::RoutableReference::getConnectionNoRouterInfo(const GetConnectionCal } } -ConnectionIPtr -IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& allEndpoints, bool& comp) const -{ - vector<EndpointIPtr> endpoints = filterEndpoints(allEndpoints); - if(endpoints.empty()) - { - throw Ice::NoEndpointException(__FILE__, __LINE__, toString()); - } - - OutgoingConnectionFactoryPtr factory = getInstance()->outgoingConnectionFactory(); - Ice::ConnectionIPtr connection; - if(getCacheConnection() || endpoints.size() == 1) - { - // - // Get an existing connection or create one if there's no - // existing connection to one of the given endpoints. - // - connection = factory->create(endpoints, false, getEndpointSelection(), comp); - } - else - { - // - // Go through the list of endpoints and try to create the - // connection until it succeeds. This is different from just - // calling create() with the given endpoints since this might - // create a new connection even if there's an existing - // connection for one of the endpoints. - // - - IceUtil::UniquePtr<LocalException> exception; - vector<EndpointIPtr> endpoint; - endpoint.push_back(0); - - for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p) - { - try - { - endpoint.back() = *p; - connection = factory->create(endpoint, p + 1 == endpoints.end(), getEndpointSelection(), comp); - break; - } - catch(const LocalException& ex) - { - exception.reset(ex.ice_clone()); - } - } - - if(!connection) - { - assert(exception.get()); - exception->ice_throw(); - } - } - - assert(connection); - - // - // If we have a router, set the object adapter for this router - // (if any) to the new connection, so that callbacks from the - // router can be received over this new connection. - // - if(_routerInfo && _routerInfo->getAdapter()) - { - connection->setAdapter(_routerInfo->getAdapter()); - } - - return connection; -} - void IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& allEndpoints, const GetConnectionCallbackPtr& callback) const diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index ff27cb6d638..7da0a673eb7 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -130,7 +130,6 @@ public: // // Get a suitable connection for this reference. // - virtual Ice::ConnectionIPtr getConnection(bool&) const = 0; virtual void getConnection(const GetConnectionCallbackPtr&) const = 0; virtual bool operator==(const Reference&) const; @@ -206,7 +205,6 @@ public: virtual std::string toString() const; virtual Ice::PropertyDict toProperty(const std::string&) const; - virtual Ice::ConnectionIPtr getConnection(bool&) const; virtual void getConnection(const GetConnectionCallbackPtr&) const; virtual bool operator==(const Reference&) const; @@ -270,11 +268,9 @@ public: virtual ReferencePtr clone() const; - virtual Ice::ConnectionIPtr getConnection(bool&) const; virtual void getConnection(const GetConnectionCallbackPtr&) const; virtual void getConnectionNoRouterInfo(const GetConnectionCallbackPtr&) const; - Ice::ConnectionIPtr createConnection(const std::vector<EndpointIPtr>&, bool&) const; void createConnection(const std::vector<EndpointIPtr>&, const GetConnectionCallbackPtr&) const; void applyOverrides(std::vector<EndpointIPtr>&) const; diff --git a/cpp/src/Ice/WSEndpoint.cpp b/cpp/src/Ice/WSEndpoint.cpp index f9eabad59d9..3cba801d782 100644 --- a/cpp/src/Ice/WSEndpoint.cpp +++ b/cpp/src/Ice/WSEndpoint.cpp @@ -179,17 +179,6 @@ IceInternal::WSEndpoint::transceiver() const return 0; } -vector<ConnectorPtr> -IceInternal::WSEndpoint::connectors(Ice::EndpointSelectionType selType) const -{ - vector<ConnectorPtr> connectors = _delegate->connectors(selType); - for(vector<ConnectorPtr>::iterator p = connectors.begin(); p != connectors.end(); ++p) - { - *p = new WSConnector(_instance, *p, _delegate->host(), _delegate->port(), _resource); - } - return connectors; -} - void IceInternal::WSEndpoint::connectors_async(Ice::EndpointSelectionType selType, const EndpointI_connectorsPtr& callback) const diff --git a/cpp/src/Ice/WSEndpoint.h b/cpp/src/Ice/WSEndpoint.h index a5aa3af5908..5d00f243e60 100644 --- a/cpp/src/Ice/WSEndpoint.h +++ b/cpp/src/Ice/WSEndpoint.h @@ -43,7 +43,6 @@ public: virtual bool secure() const; virtual TransceiverPtr transceiver() const; - virtual std::vector<ConnectorPtr> connectors(Ice::EndpointSelectionType) const; virtual void connectors_async(Ice::EndpointSelectionType, const EndpointI_connectorsPtr&) const; virtual AcceptorPtr acceptor(const std::string&) const; |