diff options
author | Marc Laukien <marc@zeroc.com> | 2003-01-30 16:17:35 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2003-01-30 16:17:35 +0000 |
commit | ee691ff3fa0882ffa02117b5156f76e5af2ea9be (patch) | |
tree | 5aa661cbb4a0d521512e15631dec2b066719f01c /cpp | |
parent | disable SSLv2 (diff) | |
download | ice-ee691ff3fa0882ffa02117b5156f76e5af2ea9be.tar.bz2 ice-ee691ff3fa0882ffa02117b5156f76e5af2ea9be.tar.xz ice-ee691ff3fa0882ffa02117b5156f76e5af2ea9be.zip |
compression cleanup
Diffstat (limited to 'cpp')
25 files changed, 438 insertions, 199 deletions
diff --git a/cpp/doc/ProxiesEndpoints.sgml b/cpp/doc/ProxiesEndpoints.sgml index 63610e819c0..edebaf44b99 100644 --- a/cpp/doc/ProxiesEndpoints.sgml +++ b/cpp/doc/ProxiesEndpoints.sgml @@ -23,7 +23,6 @@ All Rights Reserved <arg>-d</arg> <arg>-D</arg> <arg>-s</arg> -<arg>-c</arg> </group> <group> <arg choice=plain> @ <replaceable>adapter_id</replaceable></arg> @@ -74,10 +73,6 @@ Proxy options configure the invocation mode: <entry>-s</entry> <entry>Configures the proxy for secure invocations.</entry> </row> -<row> -<entry>-c</entry> -<entry>Configures the proxy for protocol compression. (C++ only)</entry> -</row> </tbody> </tgroup> </informaltable> @@ -202,6 +197,7 @@ follow. <arg>-h <replaceable>host</replaceable></arg> <arg>-p <replaceable>port</replaceable></arg> <arg>-t <replaceable>timeout</replaceable></arg> +<arg>-z</arg> </cmdsynopsis> </section> @@ -248,6 +244,14 @@ occurs, the application receives <literal>Ice::TimeoutException</literal>. <entry>Determines the default timeout that is advertised in proxies created by the object adapter.</entry> </row> +<row> +<entry>-z</entry> +<entry>Specifies bzip2 compression.</entry> +<entry>Determines whether compressed requests are sent.</entry> +<entry>Determines whether compressed responses are sent, as well as +whether compression is advertised in proxies created by the +adapter.</entry> +</row> </tbody> </tgroup> </informaltable> @@ -266,6 +270,7 @@ created by the object adapter.</entry> <arg>-h <replaceable>host</replaceable></arg> <arg>-p <replaceable>port</replaceable></arg> <arg>-c</arg> +<arg>-z</arg> </cmdsynopsis> </section> @@ -308,6 +313,13 @@ is not specified or <replaceable>port</replaceable> is zero.</entry> <entry>Causes the server to connect to the socket of the first peer that sends a datagram to this endpoint.</entry> </row> +<row> +<entry>-z</entry> +<entry>Specifies bzip2 compression.</entry> +<entry>Determines whether compressed requests are sent.</entry> +<entry>Determines whether compression is advertised in proxies created +by the adapter.</entry> +</row> </tbody> </tgroup> </informaltable> @@ -326,6 +338,7 @@ that sends a datagram to this endpoint.</entry> <arg>-h <replaceable>host</replaceable></arg> <arg>-p <replaceable>port</replaceable></arg> <arg>-t <replaceable>timeout</replaceable></arg> +<arg>-z</arg> </cmdsynopsis> </section> @@ -372,6 +385,14 @@ occurs, the application receives <literal>Ice::TimeoutException</literal>. <entry>Determines the default timeout that is advertised in proxies created by the object adapter.</entry> </row> +<row> +<entry>-z</entry> +<entry>Specifies bzip2 compression.</entry> +<entry>Determines whether compressed requests are sent.</entry> +<entry>Determines whether compressed responses are sent, as well as +whether compression is advertised in proxies created by the +adapter.</entry> +</row> </tbody> </tgroup> </informaltable> diff --git a/cpp/include/Ice/Incoming.h b/cpp/include/Ice/Incoming.h index a6c0564977c..50870e31ebb 100644 --- a/cpp/include/Ice/Incoming.h +++ b/cpp/include/Ice/Incoming.h @@ -29,7 +29,7 @@ class ICE_API IncomingBase : public IceUtil::noncopyable { protected: - IncomingBase(Instance*, Connection*, const Ice::ObjectAdapterPtr&, bool, bool); + IncomingBase(Instance*, Connection*, const Ice::ObjectAdapterPtr&, bool); IncomingBase(IncomingBase& in); // Adopts the argument. It must not be used afterwards. void __finishInvoke(); @@ -48,7 +48,6 @@ protected: Connection* _connection; bool _response; - bool _compress; BasicStream _is; BasicStream _os; @@ -58,7 +57,7 @@ class ICE_API Incoming : public IncomingBase { public: - Incoming(Instance*, Connection*, const Ice::ObjectAdapterPtr&, bool, bool); + Incoming(Instance*, Connection*, const Ice::ObjectAdapterPtr&, bool); void invoke(const ServantManagerPtr&); diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index 4c0f6c870cc..9cc617474d5 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -59,7 +59,6 @@ private: void warning() const; ConnectionPtr _connection; - bool _compress; // // We need a separate InstancePtr, because _is and _os only hold a diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index 5f1080b26f1..75a4eaa5e94 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -17,7 +17,6 @@ #include <Ice/LoggerUtil.h> #include <Ice/Properties.h> #include <Ice/TraceUtil.h> -#include <Ice/DefaultsAndOverrides.h> #include <Ice/Transceiver.h> #include <Ice/ThreadPool.h> #include <Ice/ConnectionMonitor.h> @@ -300,7 +299,7 @@ IceInternal::Connection::prepareRequest(BasicStream* os) } void -IceInternal::Connection::sendRequest(Outgoing* out, bool oneway, bool compress) +IceInternal::Connection::sendRequest(Outgoing* out, bool oneway) { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); @@ -332,16 +331,14 @@ IceInternal::Connection::sendRequest(Outgoing* out, bool oneway, bool compress) copy(p, p + sizeof(Int), os->b.begin() + headerSize); } + bool compress; if(os->b.size() < 100) // Don't compress if message size is smaller than 100 bytes. { compress = false; } else { - if(_defaultsAndOverrides->overrideCompress) - { - compress = _defaultsAndOverrides->overrideCompressValue; - } + compress = _endpoint->compress(); } if(compress) @@ -406,7 +403,7 @@ IceInternal::Connection::sendRequest(Outgoing* out, bool oneway, bool compress) } void -IceInternal::Connection::sendAsyncRequest(const OutgoingAsyncPtr& out, bool compress) +IceInternal::Connection::sendAsyncRequest(const OutgoingAsyncPtr& out) { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); @@ -435,16 +432,14 @@ IceInternal::Connection::sendAsyncRequest(const OutgoingAsyncPtr& out, bool comp p = reinterpret_cast<const Byte*>(&requestId); copy(p, p + sizeof(Int), os->b.begin() + headerSize); + bool compress; if(os->b.size() < 100) // Don't compress if message size is smaller than 100 bytes. { compress = false; } else { - if(_defaultsAndOverrides->overrideCompress) - { - compress = _defaultsAndOverrides->overrideCompressValue; - } + compress = _endpoint->compress(); } if(compress) @@ -561,7 +556,7 @@ IceInternal::Connection::abortBatchRequest() } void -IceInternal::Connection::flushBatchRequest(bool compress) +IceInternal::Connection::flushBatchRequest() { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); @@ -587,16 +582,14 @@ IceInternal::Connection::flushBatchRequest(bool compress) p = reinterpret_cast<const Byte*>(&_batchRequestNum); copy(p, p + sizeof(Int), _batchStream.b.begin() + headerSize); + bool compress; if(_batchStream.b.size() < 100) // Don't compress if message size is smaller than 100 bytes. { compress = false; } else { - if(_defaultsAndOverrides->overrideCompress) - { - compress = _defaultsAndOverrides->overrideCompressValue; - } + compress = _endpoint->compress(); } if(compress) @@ -661,7 +654,7 @@ IceInternal::Connection::flushBatchRequest(bool compress) } void -IceInternal::Connection::sendResponse(BasicStream* os, bool compress) +IceInternal::Connection::sendResponse(BasicStream* os) { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); @@ -677,16 +670,14 @@ IceInternal::Connection::sendResponse(BasicStream* os, bool compress) return; } + bool compress; if(os->b.size() < 100) // Don't compress if message size is smaller than 100 bytes. { compress = false; } else { - if(_defaultsAndOverrides->overrideCompress) - { - compress = _defaultsAndOverrides->overrideCompressValue; - } + compress = _endpoint->compress(); } if(compress) @@ -853,7 +844,6 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa Int invoke = 0; Int requestId = 0; - bool compress = false; { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); @@ -889,7 +879,6 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa BasicStream ustream(_instance.get()); doUncompress(stream, ustream); stream.b.swap(ustream.b); - compress = true; } stream.i = stream.b.begin() + headerSize; @@ -1138,7 +1127,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa // Prepare the invocation. // bool response = !_endpoint->datagram() && requestId != 0; - Incoming in(_instance.get(), this, _adapter, response, compress); + Incoming in(_instance.get(), this, _adapter, response); BasicStream* is = in.is(); stream.swap(*is); BasicStream* os = in.os(); @@ -1238,7 +1227,6 @@ IceInternal::Connection::Connection(const InstancePtr& instance, _adapter(adapter), _logger(_instance->logger()), // Chached for better performance. _traceLevels(_instance->traceLevels()), // Chached for better performance. - _defaultsAndOverrides(_instance->defaultsAndOverrides()), // Chached for better performance. _registeredWithPool(false), _warn(false), _acmTimeout(0), diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h index 00ff87b038a..3275943faa5 100644 --- a/cpp/src/Ice/Connection.h +++ b/cpp/src/Ice/Connection.h @@ -28,7 +28,6 @@ #include <Ice/LoggerF.h> #include <Ice/TraceLevelsF.h> #include <Ice/OutgoingAsyncF.h> -#include <Ice/DefaultsAndOverridesF.h> #include <Ice/EventHandler.h> namespace Ice @@ -70,15 +69,15 @@ public: void decProxyCount(); void prepareRequest(BasicStream*); - void sendRequest(Outgoing*, bool, bool); - void sendAsyncRequest(const OutgoingAsyncPtr&, bool); + void sendRequest(Outgoing*, bool); + void sendAsyncRequest(const OutgoingAsyncPtr&); void prepareBatchRequest(BasicStream*); void finishBatchRequest(BasicStream*); void abortBatchRequest(); - void flushBatchRequest(bool); + void flushBatchRequest(); - void sendResponse(BasicStream*, bool); + void sendResponse(BasicStream*); void sendNoResponse(); int timeout() const; @@ -139,7 +138,6 @@ private: const Ice::LoggerPtr _logger; const TraceLevelsPtr _traceLevels; - const DefaultsAndOverridesPtr _defaultsAndOverrides; bool _registeredWithPool; diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index 319eb011ac6..69484964d65 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -132,6 +132,11 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointPtr>& endpts { *q = (*q)->timeout(defaultsAndOverrides->overrideTimeoutValue); } + + if(defaultsAndOverrides->overrideCompress) + { + *q = (*q)->compress(defaultsAndOverrides->overrideCompressValue); + } } // @@ -334,11 +339,17 @@ IceInternal::OutgoingConnectionFactory::setRouter(const RouterPrx& router) for(p = proxy->__reference()->endpoints.begin(); p != proxy->__reference()->endpoints.end(); ++p) { EndpointPtr endpoint = *p; + if(defaultsAndOverrides->overrideTimeout) { endpoint = endpoint->timeout(defaultsAndOverrides->overrideTimeoutValue); } + if(defaultsAndOverrides->overrideCompress) + { + endpoint = endpoint->compress(defaultsAndOverrides->overrideCompressValue); + } + pair<multimap<EndpointPtr, ConnectionPtr>::const_iterator, multimap<EndpointPtr, ConnectionPtr>::const_iterator> r = _connections.equal_range(endpoint); @@ -645,11 +656,17 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance _state(StateHolding) { DefaultsAndOverridesPtr defaultsAndOverrides = _instance->defaultsAndOverrides(); + if(defaultsAndOverrides->overrideTimeout) { const_cast<EndpointPtr&>(_endpoint) = _endpoint->timeout(defaultsAndOverrides->overrideTimeoutValue); } + if(defaultsAndOverrides->overrideCompress) + { + const_cast<EndpointPtr&>(_endpoint) = _endpoint->compress(defaultsAndOverrides->overrideCompressValue); + } + const_cast<TransceiverPtr&>(_transceiver) = _endpoint->serverTransceiver(const_cast<EndpointPtr&>(_endpoint)); if(_transceiver) { diff --git a/cpp/src/Ice/Endpoint.h b/cpp/src/Ice/Endpoint.h index 2b39c65f2c3..6aa083e8953 100644 --- a/cpp/src/Ice/Endpoint.h +++ b/cpp/src/Ice/Endpoint.h @@ -27,7 +27,7 @@ namespace IceInternal class BasicStream; -class ICE_PROTOCOL_API Endpoint : public ::IceUtil::Shared +class ICE_PROTOCOL_API Endpoint : public IceUtil::Shared { public: @@ -44,20 +44,33 @@ public: // // Return the endpoint type. // - virtual ::Ice::Short type() const = 0; + virtual Ice::Short type() const = 0; // // Return the timeout for the endpoint in milliseconds. 0 means // non-blocking, -1 means no timeout. // - virtual ::Ice::Int timeout() const = 0; + virtual Ice::Int timeout() const = 0; // // Return a new endpoint with a different timeout value, provided // that timeouts are supported by the endpoint. Otherwise the same // endpoint is returned. // - virtual EndpointPtr timeout(::Ice::Int) const = 0; + virtual EndpointPtr timeout(Ice::Int) const = 0; + + // + // Return true if the endpoints support bzip2 compress, or false + // otherwise. + // + virtual bool compress() const = 0; + + // + // Return a new endpoint with a different compression value, + // provided that compression is supported by the + // endpoint. Otherwise the same endpoint is returned. + // + virtual EndpointPtr compress(bool) const = 0; // // Return true if the endpoint is datagram-based. diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 361fa963929..7b10d0eec54 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -32,10 +32,9 @@ using namespace IceInternal; IceInternal::IncomingBase::IncomingBase(Instance* instance, Connection* connection, const ObjectAdapterPtr& adapter, - bool response, bool compress) : + bool response) : _connection(connection), _response(response), - _compress(compress), _is(instance), _os(instance) { @@ -49,7 +48,6 @@ IceInternal::IncomingBase::IncomingBase(IncomingBase& in) : _cookie(in._cookie), _connection(in._connection), _response(in._response), - _compress(in._compress), _is(in._is.instance()), _os(in._os.instance()) { @@ -74,7 +72,7 @@ IceInternal::IncomingBase::__finishInvoke() // if(_response) { - _connection->sendResponse(&_os, _compress); + _connection->sendResponse(&_os); } else { @@ -115,8 +113,8 @@ IceInternal::IncomingBase::__warning(const string& msg) const IceInternal::Incoming::Incoming(Instance* instance, Connection* connection, const ObjectAdapterPtr& adapter, - bool response, bool compress) : - IncomingBase(instance, connection, adapter, response, compress) + bool response) : + IncomingBase(instance, connection, adapter, response) { } diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index e8b2c6858de..50dd2cfa867 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -356,7 +356,7 @@ Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) // vector<EndpointPtr> endpoints; ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, - false, false, "", endpoints, 0, 0, this, true); + false, "", endpoints, 0, 0, this, true); return _instance->proxyFactory()->referenceToProxy(ref); } @@ -659,7 +659,7 @@ Ice::ObjectAdapterI::newProxy(const Identity& ident) const // vector<EndpointPtr> endpoints; ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, - false, false, _id, endpoints, 0, 0, 0, true); + false, _id, endpoints, 0, 0, 0, true); // // Return a proxy for the reference. @@ -691,7 +691,7 @@ Ice::ObjectAdapterI::newDirectProxy(const Identity& ident) const // Create a reference and return a proxy for this reference. // ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, - false, false, "", endpoints, 0, 0, 0, true); + false, "", endpoints, 0, 0, 0, true); return _instance->proxyFactory()->referenceToProxy(ref); } diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index a9725607a0c..95b32218e70 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -108,7 +108,7 @@ IceInternal::Outgoing::invoke() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - _connection->sendRequest(this, false, _reference->compress); + _connection->sendRequest(this, false); _state = StateInProgress; Int timeout = _connection->timeout(); @@ -175,7 +175,7 @@ IceInternal::Outgoing::invoke() case Reference::ModeOneway: case Reference::ModeDatagram: { - _connection->sendRequest(this, true, _reference->compress); + _connection->sendRequest(this, true); _state = StateInProgress; break; } diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index 601770612d1..e52b2ded9f0 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -48,7 +48,6 @@ IceInternal::OutgoingAsync::__setup(const ConnectionPtr& connection, const Refer const string& operation, OperationMode mode, const Context& context) { _connection = connection; - _compress = ref->compress; _instance = ref->instance; delete _is; delete _os; @@ -80,7 +79,7 @@ IceInternal::OutgoingAsync::__setup(const ConnectionPtr& connection, const Refer void IceInternal::OutgoingAsync::__invoke() { - _connection->sendAsyncRequest(this, _compress); + _connection->sendAsyncRequest(this); if(_connection->timeout() >= 0) { _absoluteTimeout = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_connection->timeout()); diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index a37e9ac55a0..97a7d33ddb0 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -923,7 +923,7 @@ IceDelegateM::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb, void IceDelegateM::Ice::Object::ice_flush() { - __connection->flushBatchRequest(__reference->compress); + __connection->flushBatchRequest(); } void @@ -1289,7 +1289,22 @@ IceDelegateD::Ice::Object::setup(const ReferencePtr& ref, const ObjectAdapterPtr bool Ice::proxyIdentityLess(const ObjectPrx& lhs, const ObjectPrx& rhs) { - return lhs->ice_getIdentity() < rhs->ice_getIdentity(); + if(!lhs && !rhs) + { + return false; + } + else if(!lhs && rhs) + { + return true; + } + else if(lhs && !rhs) + { + return false; + } + else + { + return lhs->ice_getIdentity() < rhs->ice_getIdentity(); + } } bool @@ -1301,31 +1316,46 @@ Ice::proxyIdentityEqual(const ObjectPrx& lhs, const ObjectPrx& rhs) bool Ice::proxyIdentityAndFacetLess(const ObjectPrx& lhs, const ObjectPrx& rhs) { - Identity lhsIdentity = lhs->ice_getIdentity(); - Identity rhsIdentity = rhs->ice_getIdentity(); - - if(lhsIdentity < rhsIdentity) - { - return true; - } - else if(rhsIdentity < lhsIdentity) + if(!lhs && !rhs) { return false; } - - FacetPath lhsFacet = lhs->ice_getFacet(); - FacetPath rhsFacet = rhs->ice_getFacet(); - - if(lhsFacet < rhsFacet) + else if(!lhs && rhs) { return true; } - else if(rhsFacet < lhsFacet) + else if(lhs && !rhs) { return false; } - - return false; + else + { + Identity lhsIdentity = lhs->ice_getIdentity(); + Identity rhsIdentity = rhs->ice_getIdentity(); + + if(lhsIdentity < rhsIdentity) + { + return true; + } + else if(rhsIdentity < lhsIdentity) + { + return false; + } + + FacetPath lhsFacet = lhs->ice_getFacet(); + FacetPath rhsFacet = rhs->ice_getFacet(); + + if(lhsFacet < rhsFacet) + { + return true; + } + else if(rhsFacet < lhsFacet) + { + return false; + } + + return false; + } } bool diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index 18f3443bb0d..9506c0eb1db 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -60,11 +60,6 @@ IceInternal::Reference::operator==(const Reference& r) const return false; } - if(compress != r.compress) - { - return false; - } - if(adapterId != r.adapterId) { return false; @@ -148,15 +143,6 @@ IceInternal::Reference::operator<(const Reference& r) const return false; } - if(!compress && r.compress) - { - return true; - } - else if(r.compress < compress) - { - return false; - } - if(adapterId < r.adapterId) { return true; @@ -228,8 +214,6 @@ IceInternal::Reference::streamWrite(BasicStream* s) const s->write(secure); - s->write(compress); - s->writeSize(Ice::Int(endpoints.size())); if(!endpoints.empty()) @@ -337,11 +321,6 @@ IceInternal::Reference::toString() const s << " -s"; } - if(compress) - { - s << " -c"; - } - if(!endpoints.empty()) { assert(adapterId.empty()); @@ -384,7 +363,7 @@ IceInternal::Reference::changeIdentity(const Identity& newIdentity) const } else { - return instance->referenceFactory()->create(newIdentity, facet, mode, secure, compress, adapterId, + return instance->referenceFactory()->create(newIdentity, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -399,14 +378,14 @@ IceInternal::Reference::changeFacet(const FacetPath& newFacet) const } else { - return instance->referenceFactory()->create(identity, newFacet, mode, secure, compress, adapterId, + return instance->referenceFactory()->create(identity, newFacet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } } ReferencePtr -IceInternal::Reference::changeTimeout(int timeout) const +IceInternal::Reference::changeTimeout(int newTimeout) const { // // We change the timeout settings in all endpoints. @@ -416,7 +395,7 @@ IceInternal::Reference::changeTimeout(int timeout) const vector<EndpointPtr> newEndpoints; for(p = endpoints.begin(); p != endpoints.end(); ++p) { - newEndpoints.push_back((*p)->timeout(timeout)); + newEndpoints.push_back((*p)->timeout(newTimeout)); } // @@ -428,8 +407,8 @@ IceInternal::Reference::changeTimeout(int timeout) const { try { - RouterPrx newRouter = RouterPrx::uncheckedCast(routerInfo->getRouter()->ice_timeout(timeout)); - ObjectPrx newClientProxy = routerInfo->getClientProxy()->ice_timeout(timeout); + RouterPrx newRouter = RouterPrx::uncheckedCast(routerInfo->getRouter()->ice_timeout(newTimeout)); + ObjectPrx newClientProxy = routerInfo->getClientProxy()->ice_timeout(newTimeout); newRouterInfo = instance->routerManager()->get(newRouter); newRouterInfo->setClientProxy(newClientProxy); } @@ -446,11 +425,11 @@ IceInternal::Reference::changeTimeout(int timeout) const LocatorInfoPtr newLocatorInfo; if(locatorInfo) { - LocatorPrx newLocator = LocatorPrx::uncheckedCast(locatorInfo->getLocator()->ice_timeout(timeout)); + LocatorPrx newLocator = LocatorPrx::uncheckedCast(locatorInfo->getLocator()->ice_timeout(newTimeout)); newLocatorInfo = instance->locatorManager()->get(newLocator); } - return instance->referenceFactory()->create(identity, facet, mode, secure, compress, adapterId, + return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, newEndpoints, newRouterInfo, newLocatorInfo, reverseAdapter, collocationOptimization); } @@ -464,7 +443,7 @@ IceInternal::Reference::changeMode(Mode newMode) const } else { - return instance->referenceFactory()->create(identity, facet, newMode, secure, compress, adapterId, + return instance->referenceFactory()->create(identity, facet, newMode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -479,7 +458,7 @@ IceInternal::Reference::changeSecure(bool newSecure) const } else { - return instance->referenceFactory()->create(identity, facet, mode, newSecure, compress, adapterId, + return instance->referenceFactory()->create(identity, facet, mode, newSecure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -488,16 +467,51 @@ IceInternal::Reference::changeSecure(bool newSecure) const ReferencePtr IceInternal::Reference::changeCompress(bool newCompress) const { - if(newCompress == compress) + // + // We change the compress settings in all endpoints. + // + vector<EndpointPtr>::const_iterator p; + + vector<EndpointPtr> newEndpoints; + for(p = endpoints.begin(); p != endpoints.end(); ++p) { - return ReferencePtr(const_cast<Reference*>(this)); + newEndpoints.push_back((*p)->compress(newCompress)); } - else + + // + // If we have a router, we also change the compress settings on the + // router and the router's client proxy. + // + RouterInfoPtr newRouterInfo; + if(routerInfo) { - return instance->referenceFactory()->create(identity, facet, mode, secure, newCompress, adapterId, - endpoints, routerInfo, locatorInfo, reverseAdapter, - collocationOptimization); + try + { + RouterPrx newRouter = RouterPrx::uncheckedCast(routerInfo->getRouter()->ice_compress(newCompress)); + ObjectPrx newClientProxy = routerInfo->getClientProxy()->ice_compress(newCompress); + newRouterInfo = instance->routerManager()->get(newRouter); + newRouterInfo->setClientProxy(newClientProxy); + } + catch(const NoEndpointException&) + { + // Ignore non-existing client proxies. + } } + + // + // If we have a locator, we also change the compress settings on the + // locator. + // + LocatorInfoPtr newLocatorInfo; + if(locatorInfo) + { + LocatorPrx newLocator = LocatorPrx::uncheckedCast(locatorInfo->getLocator()->ice_compress(newCompress)); + newLocatorInfo = instance->locatorManager()->get(newLocator); + } + + return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + newEndpoints, newRouterInfo, newLocatorInfo, reverseAdapter, + collocationOptimization); } ReferencePtr @@ -509,7 +523,7 @@ IceInternal::Reference::changeAdapterId(const string& newAdapterId) const } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, compress, newAdapterId, + return instance->referenceFactory()->create(identity, facet, mode, secure, newAdapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -524,7 +538,7 @@ IceInternal::Reference::changeEndpoints(const vector<EndpointPtr>& newEndpoints) } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, compress, adapterId, + return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, newEndpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -541,7 +555,7 @@ IceInternal::Reference::changeRouter(const RouterPrx& newRouter) const } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, compress, adapterId, + return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, endpoints, newRouterInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -558,7 +572,7 @@ IceInternal::Reference::changeLocator(const LocatorPrx& newLocator) const } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, compress, adapterId, + return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, endpoints, routerInfo, newLocatorInfo, reverseAdapter, collocationOptimization); } @@ -573,7 +587,7 @@ IceInternal::Reference::changeCollocationOptimization(bool newCollocationOptimiz } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, compress, adapterId, + return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, newCollocationOptimization); } @@ -585,7 +599,7 @@ IceInternal::Reference::changeDefault() const RouterInfoPtr routerInfo = instance->routerManager()->get(instance->referenceFactory()->getDefaultRouter()); LocatorInfoPtr locatorInfo = instance->locatorManager()->get(instance->referenceFactory()->getDefaultLocator()); - return instance->referenceFactory()->create(identity, FacetPath(), ModeTwoway, false, false, adapterId, + return instance->referenceFactory()->create(identity, FacetPath(), ModeTwoway, false, adapterId, endpoints, routerInfo, locatorInfo, 0, true); } @@ -594,7 +608,6 @@ IceInternal::Reference::Reference(const InstancePtr& inst, const FacetPath& facPath, Mode md, bool sec, - bool com, const string& adptid, const vector<EndpointPtr>& endpts, const RouterInfoPtr& rtrInfo, @@ -606,7 +619,6 @@ IceInternal::Reference::Reference(const InstancePtr& inst, facet(facPath), mode(md), secure(sec), - compress(com), adapterId(adptid), endpoints(endpts), routerInfo(rtrInfo), @@ -647,8 +659,6 @@ IceInternal::Reference::Reference(const InstancePtr& inst, h = 5 * h + static_cast<Int>(secure); - h = 5 * h + static_cast<Int>(compress); - // // TODO: Should we also take the endpoints and other stuff into // account for hash calculation? Perhaps not, the code above diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index 64148113414..eda2b5746c8 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -68,7 +68,6 @@ public: const Ice::FacetPath facet; const Mode mode; const bool secure; - const bool compress; const std::string adapterId; const std::vector<EndpointPtr> endpoints; const RouterInfoPtr routerInfo; // Null if no router is used. @@ -96,7 +95,7 @@ public: private: - Reference(const InstancePtr&, const Ice::Identity&, const Ice::FacetPath&, Mode, bool, bool, + Reference(const InstancePtr&, const Ice::Identity&, const Ice::FacetPath&, Mode, bool, const std::string&, const std::vector<EndpointPtr>&, const RouterInfoPtr&, const LocatorInfoPtr&, const Ice::ObjectAdapterPtr&, bool); friend class ReferenceFactory; diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index c9a467d5004..88d95291a2a 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -35,7 +35,6 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const vector<string>& facet, Reference::Mode mode, bool secure, - bool compress, const string& adapterId, const vector<EndpointPtr>& endpoints, const RouterInfoPtr& routerInfo, @@ -58,7 +57,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // // Create new reference // - ReferencePtr ref = new Reference(_instance, ident, facet, mode, secure, compress, adapterId, + ReferencePtr ref = new Reference(_instance, ident, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); // @@ -210,7 +209,6 @@ IceInternal::ReferenceFactory::create(const string& str) vector<string> facet; Reference::Mode mode = Reference::ModeTwoway; bool secure = false; - bool compress = false; string adapter; while(true) @@ -422,18 +420,6 @@ IceInternal::ReferenceFactory::create(const string& str) break; } - case 'c': - { - if(!argument.empty()) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - compress = true; - break; - } - default: { ProxyParseException ex(__FILE__, __LINE__); @@ -506,7 +492,7 @@ IceInternal::ReferenceFactory::create(const string& str) RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter()); LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); - return create(ident, facet, mode, secure, compress, adapter, endpoints, routerInfo, locatorInfo, 0, true); + return create(ident, facet, mode, secure, adapter, endpoints, routerInfo, locatorInfo, 0, true); } ReferencePtr @@ -536,9 +522,6 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) bool secure; s->read(secure); - bool compress; - s->read(compress); - vector<EndpointPtr> endpoints; string adapterId; @@ -561,7 +544,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter()); LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); - return create(ident, facet, mode, secure, compress, adapterId, endpoints, routerInfo, locatorInfo, 0, true); + return create(ident, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, 0, true); } void diff --git a/cpp/src/Ice/ReferenceFactory.h b/cpp/src/Ice/ReferenceFactory.h index 296e4ba735f..78d9884ff1a 100644 --- a/cpp/src/Ice/ReferenceFactory.h +++ b/cpp/src/Ice/ReferenceFactory.h @@ -28,7 +28,7 @@ class ReferenceFactory : public ::IceUtil::Shared, public ::IceUtil::Mutex { public: - ReferencePtr create(const Ice::Identity&, const std::vector<std::string>&, Reference::Mode, bool, bool, + ReferencePtr create(const Ice::Identity&, const std::vector<std::string>&, Reference::Mode, bool, const std::string&, const std::vector<EndpointPtr>&, const RouterInfoPtr&, const LocatorInfoPtr&, const Ice::ObjectAdapterPtr&, bool); ReferencePtr create(const std::string&); diff --git a/cpp/src/Ice/TcpEndpoint.cpp b/cpp/src/Ice/TcpEndpoint.cpp index 1ce1aebaed0..08393fb45d3 100644 --- a/cpp/src/Ice/TcpEndpoint.cpp +++ b/cpp/src/Ice/TcpEndpoint.cpp @@ -26,18 +26,20 @@ using namespace std; using namespace Ice; using namespace IceInternal; -IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string& ho, Int po, Int ti) : +IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string& ho, Int po, Int ti, bool co) : _instance(instance), _host(ho), _port(po), - _timeout(ti) + _timeout(ti), + _compress(co) { } IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string& str) : _instance(instance), _port(0), - _timeout(-1) + _timeout(-1), + _compress(false) { const string delim = " \t\n\r"; @@ -117,6 +119,18 @@ IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string& break; } + case 'z': + { + if(!argument.empty()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "tcp " + str; + throw ex; + } + const_cast<bool&>(_compress) = true; + break; + } + default: { EndpointParseException ex(__FILE__, __LINE__); @@ -135,12 +149,14 @@ IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string& IceInternal::TcpEndpoint::TcpEndpoint(BasicStream* s) : _instance(s->instance()), _port(0), - _timeout(-1) + _timeout(-1), + _compress(false) { s->startReadEncaps(); s->read(const_cast<string&>(_host)); s->read(const_cast<Int&>(_port)); s->read(const_cast<Int&>(_timeout)); + s->read(const_cast<bool&>(_compress)); s->endReadEncaps(); } @@ -152,6 +168,7 @@ IceInternal::TcpEndpoint::streamWrite(BasicStream* s) const s->write(_host); s->write(_port); s->write(_timeout); + s->write(_compress); s->endWriteEncaps(); } @@ -164,6 +181,10 @@ IceInternal::TcpEndpoint::toString() const { s << " -t " << _timeout; } + if(_compress) + { + s << " -z"; + } return s.str(); } @@ -188,7 +209,26 @@ IceInternal::TcpEndpoint::timeout(Int timeout) const } else { - return new TcpEndpoint(_instance, _host, _port, timeout); + return new TcpEndpoint(_instance, _host, _port, timeout, _compress); + } +} + +bool +IceInternal::TcpEndpoint::compress() const +{ + return _compress; +} + +EndpointPtr +IceInternal::TcpEndpoint::compress(bool compress) const +{ + if(compress == _compress) + { + return const_cast<TcpEndpoint*>(this); + } + else + { + return new TcpEndpoint(_instance, _host, _port, _timeout, compress); } } @@ -233,7 +273,7 @@ AcceptorPtr IceInternal::TcpEndpoint::acceptor(EndpointPtr& endp) const { TcpAcceptor* p = new TcpAcceptor(_instance, _host, _port); - endp = new TcpEndpoint(_instance, _host, p->effectivePort(), _timeout); + endp = new TcpEndpoint(_instance, _host, p->effectivePort(), _timeout, _compress); return p; } @@ -278,6 +318,11 @@ IceInternal::TcpEndpoint::operator==(const Endpoint& r) const return false; } + if(_compress != p->_compress) + { + return false; + } + if(_host != p->_host) { // @@ -331,6 +376,15 @@ IceInternal::TcpEndpoint::operator<(const Endpoint& r) const return false; } + if(!_compress && p->_compress) + { + return true; + } + else if(p->_compress < _compress) + { + return false; + } + if(_host != p->_host) { // diff --git a/cpp/src/Ice/TcpEndpoint.h b/cpp/src/Ice/TcpEndpoint.h index 48116ec333d..ff461012a18 100644 --- a/cpp/src/Ice/TcpEndpoint.h +++ b/cpp/src/Ice/TcpEndpoint.h @@ -21,21 +21,23 @@ namespace IceInternal { -const ::Ice::Short TcpEndpointType = 1; +const Ice::Short TcpEndpointType = 1; class TcpEndpoint : public Endpoint { public: - TcpEndpoint(const InstancePtr&, const std::string&, ::Ice::Int, ::Ice::Int); + TcpEndpoint(const InstancePtr&, const std::string&, Ice::Int, Ice::Int, bool); TcpEndpoint(const InstancePtr&, const std::string&); TcpEndpoint(BasicStream*); virtual void streamWrite(BasicStream*) const; virtual std::string toString() const; - virtual ::Ice::Short type() const; - virtual ::Ice::Int timeout() const; - virtual EndpointPtr timeout(::Ice::Int) const; + virtual Ice::Short type() const; + virtual Ice::Int timeout() const; + virtual EndpointPtr timeout(Ice::Int) const; + virtual bool compress() const; + virtual EndpointPtr compress(bool) const; virtual bool datagram() const; virtual bool secure() const; virtual bool unknown() const; @@ -57,8 +59,9 @@ private: // const InstancePtr _instance; const std::string _host; - const ::Ice::Int _port; - const ::Ice::Int _timeout; + const Ice::Int _port; + const Ice::Int _timeout; + const bool _compress; }; class TcpEndpointFactory : public EndpointFactory @@ -67,8 +70,8 @@ public: virtual ~TcpEndpointFactory(); - virtual ::Ice::Short type() const; - virtual ::std::string protocol() const; + virtual Ice::Short type() const; + virtual std::string protocol() const; virtual EndpointPtr create(const std::string&) const; virtual EndpointPtr read(BasicStream*) const; virtual void destroy(); diff --git a/cpp/src/Ice/UdpEndpoint.cpp b/cpp/src/Ice/UdpEndpoint.cpp index a1c3503e35b..7ba53af41ba 100644 --- a/cpp/src/Ice/UdpEndpoint.cpp +++ b/cpp/src/Ice/UdpEndpoint.cpp @@ -24,18 +24,20 @@ using namespace std; using namespace Ice; using namespace IceInternal; -IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& ho, Int po) : +IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& ho, Int po, bool co) : _instance(instance), _host(ho), _port(po), - _connect(false) + _connect(false), + _compress(co) { } IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& str) : _instance(instance), _port(0), - _connect(false) + _connect(false), + _compress(false) { const string delim = " \t\n\r"; @@ -115,6 +117,18 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& break; } + case 'z': + { + if(!argument.empty()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } + const_cast<bool&>(_compress) = true; + break; + } + default: { EndpointParseException ex(__FILE__, __LINE__); @@ -133,13 +147,15 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& IceInternal::UdpEndpoint::UdpEndpoint(BasicStream* s) : _instance(s->instance()), _port(0), - _connect(false) + _connect(false), + _compress(false) { s->startReadEncaps(); s->read(const_cast<string&>(_host)); s->read(const_cast<Int&>(_port)); // Not transmitted. //s->read(const_cast<bool&>(_connect)); + s->read(const_cast<bool&>(_compress)); s->endReadEncaps(); } @@ -152,6 +168,7 @@ IceInternal::UdpEndpoint::streamWrite(BasicStream* s) const s->write(_port); // Not transmitted. //s->write(_connect); + s->write(_compress); s->endWriteEncaps(); } @@ -164,6 +181,10 @@ IceInternal::UdpEndpoint::toString() const { s << " -c"; } + if(_compress) + { + s << " -z"; + } return s.str(); } @@ -186,6 +207,25 @@ IceInternal::UdpEndpoint::timeout(Int) const } bool +IceInternal::UdpEndpoint::compress() const +{ + return _compress; +} + +EndpointPtr +IceInternal::UdpEndpoint::compress(bool compress) const +{ + if(compress == _compress) + { + return const_cast<UdpEndpoint*>(this); + } + else + { + return new UdpEndpoint(_instance, _host, _port, compress); + } +} + +bool IceInternal::UdpEndpoint::datagram() const { return true; @@ -213,7 +253,7 @@ TransceiverPtr IceInternal::UdpEndpoint::serverTransceiver(EndpointPtr& endp) const { UdpTransceiver* p = new UdpTransceiver(_instance, _host, _port, _connect); - endp = new UdpEndpoint(_instance, _host, p->effectivePort()); + endp = new UdpEndpoint(_instance, _host, p->effectivePort(), _compress); return p; } @@ -266,6 +306,11 @@ IceInternal::UdpEndpoint::operator==(const Endpoint& r) const return false; } + if(_compress != p->_compress) + { + return false; + } + if(_connect != p->_connect) { return false; @@ -315,6 +360,15 @@ IceInternal::UdpEndpoint::operator<(const Endpoint& r) const return false; } + if(!_compress && p->_compress) + { + return true; + } + else if(p->_compress < _compress) + { + return false; + } + if(!_connect && p->_connect) { return true; diff --git a/cpp/src/Ice/UdpEndpoint.h b/cpp/src/Ice/UdpEndpoint.h index e504b8973b2..caf54950b88 100644 --- a/cpp/src/Ice/UdpEndpoint.h +++ b/cpp/src/Ice/UdpEndpoint.h @@ -21,21 +21,23 @@ namespace IceInternal { -const ::Ice::Short UdpEndpointType = 3; +const Ice::Short UdpEndpointType = 3; class UdpEndpoint : public Endpoint { public: - UdpEndpoint(const InstancePtr&, const std::string&, ::Ice::Int); + UdpEndpoint(const InstancePtr&, const std::string&, Ice::Int, bool); UdpEndpoint(const InstancePtr&, const std::string&); UdpEndpoint(BasicStream*); virtual void streamWrite(BasicStream*) const; virtual std::string toString() const; - virtual ::Ice::Short type() const; - virtual ::Ice::Int timeout() const; - virtual EndpointPtr timeout(::Ice::Int) const; + virtual Ice::Short type() const; + virtual Ice::Int timeout() const; + virtual EndpointPtr timeout(Ice::Int) const; + virtual bool compress() const; + virtual EndpointPtr compress(bool) const; virtual bool datagram() const; virtual bool secure() const; virtual bool unknown() const; @@ -57,8 +59,9 @@ private: // const InstancePtr _instance; const std::string _host; - const ::Ice::Int _port; + const Ice::Int _port; const bool _connect; + const bool _compress; }; class UdpEndpointFactory : public EndpointFactory @@ -67,8 +70,8 @@ public: virtual ~UdpEndpointFactory(); - virtual ::Ice::Short type() const; - virtual ::std::string protocol() const; + virtual Ice::Short type() const; + virtual std::string protocol() const; virtual EndpointPtr create(const std::string&) const; virtual EndpointPtr read(BasicStream*) const; virtual void destroy(); diff --git a/cpp/src/Ice/UnknownEndpoint.cpp b/cpp/src/Ice/UnknownEndpoint.cpp index fbe1b6ff3f0..03f571d7807 100644 --- a/cpp/src/Ice/UnknownEndpoint.cpp +++ b/cpp/src/Ice/UnknownEndpoint.cpp @@ -65,6 +65,18 @@ IceInternal::UnknownEndpoint::timeout(Int) const } bool +IceInternal::UnknownEndpoint::compress() const +{ + return false; +} + +EndpointPtr +IceInternal::UnknownEndpoint::compress(bool) const +{ + return const_cast<UnknownEndpoint*>(this); +} + +bool IceInternal::UnknownEndpoint::datagram() const { return false; diff --git a/cpp/src/Ice/UnknownEndpoint.h b/cpp/src/Ice/UnknownEndpoint.h index c9ffa610372..d94a57ec3c5 100644 --- a/cpp/src/Ice/UnknownEndpoint.h +++ b/cpp/src/Ice/UnknownEndpoint.h @@ -21,19 +21,21 @@ namespace IceInternal { -const ::Ice::Short UnknownEndpointType = 0; +const Ice::Short UnknownEndpointType = 0; class UnknownEndpoint : public Endpoint { public: - UnknownEndpoint(::Ice::Short, BasicStream*); + UnknownEndpoint(Ice::Short, BasicStream*); virtual void streamWrite(BasicStream*) const; virtual std::string toString() const; - virtual ::Ice::Short type() const; - virtual ::Ice::Int timeout() const; - virtual EndpointPtr timeout(::Ice::Int) const; + virtual Ice::Short type() const; + virtual Ice::Int timeout() const; + virtual EndpointPtr timeout(Ice::Int) const; + virtual bool compress() const; + virtual EndpointPtr compress(bool) const; virtual bool datagram() const; virtual bool secure() const; virtual bool unknown() const; @@ -54,8 +56,8 @@ private: // All members are const, because endpoints are immutable. // const InstancePtr _instance; - ::Ice::Short _type; - const std::vector< ::Ice::Byte> _rawBytes; + Ice::Short _type; + const std::vector<Ice::Byte> _rawBytes; }; } diff --git a/cpp/src/IceSSL/SslEndpoint.cpp b/cpp/src/IceSSL/SslEndpoint.cpp index 2bd24ed82e4..bd7b96d7361 100644 --- a/cpp/src/IceSSL/SslEndpoint.cpp +++ b/cpp/src/IceSSL/SslEndpoint.cpp @@ -26,18 +26,20 @@ using namespace std; using namespace Ice; using namespace IceInternal; -IceSSL::SslEndpoint::SslEndpoint(const OpenSSLPluginIPtr& plugin, const string& ho, Int po, Int ti) : +IceSSL::SslEndpoint::SslEndpoint(const OpenSSLPluginIPtr& plugin, const string& ho, Int po, Int ti, bool co) : _plugin(plugin), _host(ho), _port(po), - _timeout(ti) + _timeout(ti), + _compress(co) { } IceSSL::SslEndpoint::SslEndpoint(const OpenSSLPluginIPtr& plugin, const string& str) : _plugin(plugin), _port(0), - _timeout(-1) + _timeout(-1), + _compress(false) { const string delim = " \t\n\r"; @@ -117,6 +119,18 @@ IceSSL::SslEndpoint::SslEndpoint(const OpenSSLPluginIPtr& plugin, const string& break; } + case 'z': + { + if(!argument.empty()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "ssl " + str; + throw ex; + } + const_cast<bool&>(_compress) = true; + break; + } + default: { EndpointParseException ex(__FILE__, __LINE__); @@ -135,12 +149,14 @@ IceSSL::SslEndpoint::SslEndpoint(const OpenSSLPluginIPtr& plugin, const string& IceSSL::SslEndpoint::SslEndpoint(const OpenSSLPluginIPtr& plugin, BasicStream* s) : _plugin(plugin), _port(0), - _timeout(-1) + _timeout(-1), + _compress(false) { s->startReadEncaps(); s->read(const_cast<string&>(_host)); s->read(const_cast<Int&>(_port)); s->read(const_cast<Int&>(_timeout)); + s->read(const_cast<bool&>(_compress)); s->endReadEncaps(); } @@ -152,6 +168,7 @@ IceSSL::SslEndpoint::streamWrite(BasicStream* s) const s->write(_host); s->write(_port); s->write(_timeout); + s->write(_compress); s->endWriteEncaps(); } @@ -164,6 +181,10 @@ IceSSL::SslEndpoint::toString() const { s << " -t " << _timeout; } + if(_compress) + { + s << " -z"; + } return s.str(); } @@ -188,7 +209,26 @@ IceSSL::SslEndpoint::timeout(Int timeout) const } else { - return new SslEndpoint(_plugin, _host, _port, timeout); + return new SslEndpoint(_plugin, _host, _port, timeout, _compress); + } +} + +bool +IceSSL::SslEndpoint::compress() const +{ + return _compress; +} + +EndpointPtr +IceSSL::SslEndpoint::compress(bool compress) const +{ + if(compress == _compress) + { + return const_cast<SslEndpoint*>(this); + } + else + { + return new SslEndpoint(_plugin, _host, _port, _timeout, compress); } } @@ -233,7 +273,7 @@ AcceptorPtr IceSSL::SslEndpoint::acceptor(EndpointPtr& endp) const { SslAcceptor* p = new SslAcceptor(_plugin, _host, _port); - endp = new SslEndpoint(_plugin, _host, p->effectivePort(), _timeout); + endp = new SslEndpoint(_plugin, _host, p->effectivePort(), _timeout, _compress); return p; } @@ -278,6 +318,11 @@ IceSSL::SslEndpoint::operator==(const Endpoint& r) const return false; } + if(_compress != p->_compress) + { + return false; + } + if(_host != p->_host) { // @@ -331,6 +376,15 @@ IceSSL::SslEndpoint::operator<(const Endpoint& r) const return false; } + if(!_compress && p->_compress) + { + return true; + } + else if(p->_compress < _compress) + { + return false; + } + if(_host != p->_host) { // diff --git a/cpp/src/IceSSL/SslEndpoint.h b/cpp/src/IceSSL/SslEndpoint.h index 0b611d4c5c6..3cd0435a823 100644 --- a/cpp/src/IceSSL/SslEndpoint.h +++ b/cpp/src/IceSSL/SslEndpoint.h @@ -22,21 +22,23 @@ namespace IceSSL { -const ::Ice::Short SslEndpointType = 2; +const Ice::Short SslEndpointType = 2; class SslEndpoint : public IceInternal::Endpoint { public: - SslEndpoint(const IceSSL::OpenSSLPluginIPtr&, const std::string&, ::Ice::Int, ::Ice::Int); + SslEndpoint(const IceSSL::OpenSSLPluginIPtr&, const std::string&, Ice::Int, Ice::Int, bool); SslEndpoint(const IceSSL::OpenSSLPluginIPtr&, const std::string&); SslEndpoint(const IceSSL::OpenSSLPluginIPtr&, IceInternal::BasicStream*); virtual void streamWrite(IceInternal::BasicStream*) const; virtual std::string toString() const; - virtual ::Ice::Short type() const; - virtual ::Ice::Int timeout() const; - virtual IceInternal::EndpointPtr timeout(::Ice::Int) const; + virtual Ice::Short type() const; + virtual Ice::Int timeout() const; + virtual IceInternal::EndpointPtr timeout(Ice::Int) const; + virtual bool compress() const; + virtual IceInternal::EndpointPtr compress(bool) const; virtual bool datagram() const; virtual bool secure() const; virtual bool unknown() const; @@ -58,8 +60,9 @@ private: // const IceSSL::OpenSSLPluginIPtr _plugin; const std::string _host; - const ::Ice::Int _port; - const ::Ice::Int _timeout; + const Ice::Int _port; + const Ice::Int _timeout; + const bool _compress; }; class SslEndpointFactory : public IceInternal::EndpointFactory @@ -69,8 +72,8 @@ public: SslEndpointFactory(const IceSSL::OpenSSLPluginIPtr&); virtual ~SslEndpointFactory(); - virtual ::Ice::Short type() const; - virtual ::std::string protocol() const; + virtual Ice::Short type() const; + virtual std::string protocol() const; virtual IceInternal::EndpointPtr create(const std::string&) const; virtual IceInternal::EndpointPtr read(IceInternal::BasicStream*) const; virtual void destroy(); diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp index bd9284311c3..fb676802ef4 100644 --- a/cpp/test/Ice/operations/Twoways.cpp +++ b/cpp/test/Ice/operations/Twoways.cpp @@ -126,9 +126,9 @@ twoways(const Test::MyClassPrx& p) Test::MyClassPrx r; r = p->opMyClass(p, c1, c2); - test(c1 == p); - test(c2 != p); - //test(r == p); + test(Ice::proxyIdentityAndFacetEqual(c1, p)); + test(!Ice::proxyIdentityAndFacetEqual(c2, p)); + test(Ice::proxyIdentityAndFacetEqual(r, p)); test(c1->ice_getIdentity() == Ice::stringToIdentity("test")); test(c2->ice_getIdentity() == Ice::stringToIdentity("noSuchIdentity")); test(r->ice_getIdentity() == Ice::stringToIdentity("test")); @@ -146,7 +146,7 @@ twoways(const Test::MyClassPrx& p) r = p->opMyClass(0, c1, c2); test(c1 == 0); test(c2 != 0); - test(r == p); + test(Ice::proxyIdentityAndFacetEqual(r, p)); r->opVoid(); // TODO: For some reasons this test sometimes doesn't work on linux #ifdef _WIN32 |