diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Connection.cpp | 75 | ||||
-rw-r--r-- | cpp/src/Ice/Connection.h | 6 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 34 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.h | 3 | ||||
-rw-r--r-- | cpp/src/Ice/Direct.cpp | 50 | ||||
-rw-r--r-- | cpp/src/Ice/Exception.cpp | 24 | ||||
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 221 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 161 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.h | 5 | ||||
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 57 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 114 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/TraceUtil.cpp | 263 | ||||
-rw-r--r-- | cpp/src/IceSSL/RSACertificateGen.cpp | 36 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 29 |
15 files changed, 533 insertions, 547 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index 0a824b0a0fa..d23cbe9d395 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -132,20 +132,20 @@ IceInternal::Connection::activate() } void -IceInternal::Connection::incProxyUsageCount() +IceInternal::Connection::incUsageCount() { IceUtil::RecMutex::Lock sync(*this); - assert(_proxyUsageCount >= 0); - ++_proxyUsageCount; + assert(_usageCount >= 0); + ++_usageCount; } void -IceInternal::Connection::decProxyUsageCount() +IceInternal::Connection::decUsageCount() { IceUtil::RecMutex::Lock sync(*this); - assert(_proxyUsageCount > 0); - --_proxyUsageCount; - if(_proxyUsageCount == 0 && !_adapter) + assert(_usageCount > 0); + --_usageCount; + if(_usageCount == 0 && !_adapter) { assert(_requests.empty()); setState(StateClosing, CloseConnectionException(__FILE__, __LINE__)); @@ -681,23 +681,27 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa // if(invoke) { + // + // Prepare the invocation. + // Incoming in(_instance, _adapter); BasicStream* is = in.is(); - BasicStream* os = in.os(); stream.swap(*is); - - bool response = false; + BasicStream* os = 0; try { + // + // Prepare the response if necessary. + // if(!batch) { Int requestId; is->read(requestId); if(!_endpoint->datagram() && requestId != 0) // 0 means oneway. { - response = true; ++_responseCount; + os = in.os(); os->write(protocolVersion); os->write(encodingVersion); os->write(replyMsg); @@ -706,39 +710,13 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa } } + // + // Do the invocation, or multiple invocations for batch + // messages. + // do { - try - { - in.invoke(response); - } - catch(const LocalException& ex) - { - IceUtil::RecMutex::Lock sync(*this); - if(_warn) - { - Warning out(_logger); - out << "connection exception:\n" << ex << '\n' << _transceiver->toString(); - } - } - catch(const UserException& ex) - { - IceUtil::RecMutex::Lock sync(*this); - if(_warn) - { - Warning out(_logger); - out << "unknown user exception:\n" << ex << '\n' << _transceiver->toString(); - } - } - catch(...) - { - IceUtil::RecMutex::Lock sync(*this); - if(_warn) - { - Warning out(_logger); - out << "unknown exception"; - } - } + in.invoke(os != 0); } while(batch && is->i < is->b.end()); } @@ -749,13 +727,15 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa return; } - if(response) + // + // Send a response if necessary. + // + if(os != 0) { IceUtil::RecMutex::Lock sync(*this); try { - if(_state == StateClosed) { return; @@ -772,14 +752,14 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa comp = _defaultsAndOverrides->overrideComppressValue; } } - + if(comp) { // // Change message type. // os->b[2] = compressedReplyMsg; - + // // Do compression. // @@ -874,7 +854,7 @@ IceInternal::Connection::Connection(const InstancePtr& instance, _requestsHint(_requests.end()), _batchStream(_instance), _responseCount(0), - _proxyUsageCount(0), + _usageCount(0), _state(StateHolding), _registeredWithPool(false) { @@ -882,6 +862,7 @@ IceInternal::Connection::Connection(const InstancePtr& instance, IceInternal::Connection::~Connection() { + assert(_usageCount == 0); assert(_state == StateClosed); } diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h index cf110ddfce8..edf8a651488 100644 --- a/cpp/src/Ice/Connection.h +++ b/cpp/src/Ice/Connection.h @@ -45,8 +45,8 @@ public: void validate(); void hold(); void activate(); - void incProxyUsageCount(); - void decProxyUsageCount(); + void incUsageCount(); + void decUsageCount(); void prepareRequest(Outgoing*); void sendRequest(Outgoing*, bool, bool); void removeRequest(Outgoing*); @@ -113,7 +113,7 @@ private: std::auto_ptr< ::Ice::LocalException> _exception; BasicStream _batchStream; int _responseCount; - int _proxyUsageCount; + int _usageCount; State _state; bool _registeredWithPool; }; diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index 39207ed48b0..99a09ae228a 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -246,14 +246,14 @@ IceInternal::OutgoingConnectionFactory::destroy() void IceInternal::IncomingConnectionFactory::hold() { - ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); + ::IceUtil::Mutex::Lock sync(*this); setState(StateHolding); } void IceInternal::IncomingConnectionFactory::activate() { - ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); + ::IceUtil::Mutex::Lock sync(*this); setState(StateActive); } @@ -279,7 +279,7 @@ IceInternal::IncomingConnectionFactory::equivalent(const EndpointPtr& endp) cons list<ConnectionPtr> IceInternal::IncomingConnectionFactory::connections() const { - ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); + ::IceUtil::Mutex::Lock sync(*this); // // Reap destroyed connections. @@ -306,7 +306,7 @@ IceInternal::IncomingConnectionFactory::read(BasicStream&) void IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPtr& threadPool) { - ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); + ::IceUtil::Mutex::Lock sync(*this); if(_state != StateActive) { @@ -390,7 +390,7 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPt void IceInternal::IncomingConnectionFactory::finished(const ThreadPoolPtr& threadPool) { - ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); + ::IceUtil::Mutex::Lock sync(*this); threadPool->promoteFollower(); @@ -403,13 +403,10 @@ IceInternal::IncomingConnectionFactory::finished(const ThreadPoolPtr& threadPool _acceptor->close(); // - // Break cyclic object dependency. This is necessary, because - // the object adapter never clears the list of incoming - // connections it keeps. + // We don't need the adapter anymore after we closed the + // acceptor. // _adapter = 0; - - notifyAll(); // For waitUntilFinished(). } } @@ -458,9 +455,7 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance // // We don't need an adapter anymore if we don't use an - // acceptor. So we break cyclic object dependency - // now. This is necessary, because the object adapter - // never clears the list of incoming connections it keeps. + // acceptor. // _adapter = 0; } @@ -487,22 +482,11 @@ IceInternal::IncomingConnectionFactory::~IncomingConnectionFactory() void IceInternal::IncomingConnectionFactory::destroy() { - ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); + ::IceUtil::Mutex::Lock sync(*this); setState(StateClosed); } void -IceInternal::IncomingConnectionFactory::waitUntilFinished() const -{ - ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); - - while(_state != StateClosed || _adapter) - { - wait(); - } -} - -void IceInternal::IncomingConnectionFactory::setState(State state) { if(_state == state) // Don't switch twice. diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h index f7972c89de3..fe80cc699d8 100644 --- a/cpp/src/Ice/ConnectionFactory.h +++ b/cpp/src/Ice/ConnectionFactory.h @@ -53,7 +53,7 @@ private: std::map<EndpointPtr, ConnectionPtr> _connections; }; -class IncomingConnectionFactory : public EventHandler, public ::IceUtil::Monitor< ::IceUtil::Mutex> +class IncomingConnectionFactory : public EventHandler, public ::IceUtil::Mutex { public: @@ -79,7 +79,6 @@ private: IncomingConnectionFactory(const InstancePtr&, const EndpointPtr&, const ::Ice::ObjectAdapterPtr&); virtual ~IncomingConnectionFactory(); void destroy(); - void waitUntilFinished() const; friend class ::Ice::ObjectAdapterI; enum State diff --git a/cpp/src/Ice/Direct.cpp b/cpp/src/Ice/Direct.cpp index b65596c6dcd..dcaf4cb6f28 100644 --- a/cpp/src/Ice/Direct.cpp +++ b/cpp/src/Ice/Direct.cpp @@ -9,7 +9,7 @@ // ********************************************************************** #include <Ice/Direct.h> -#include <Ice/ObjectAdapter.h> +#include <Ice/ObjectAdapterI.h> // We need ObjectAdapterI, not ObjectAdapter, because of inc/decUsageCount(). #include <Ice/ServantLocator.h> #include <Ice/Reference.h> #include <Ice/Object.h> @@ -24,11 +24,13 @@ IceInternal::Direct::Direct(const Current& current) : { try { - _servant = current.adapter->identityToServant(_current.id); + dynamic_cast<ObjectAdapterI*>(_current.adapter.get())->incUsageCount(); + + _servant = _current.adapter->identityToServant(_current.id); if(!_servant && !_current.id.category.empty()) { - _locator = current.adapter->findServantLocator(_current.id.category); + _locator = _current.adapter->findServantLocator(_current.id.category); if(_locator) { _servant = _locator->locate(_current, _cookie); @@ -37,14 +39,21 @@ IceInternal::Direct::Direct(const Current& current) : if(!_servant) { - _locator = current.adapter->findServantLocator(""); + _locator = _current.adapter->findServantLocator(""); if(_locator) { _servant = _locator->locate(_current, _cookie); } } - if(_servant && !_current.facet.empty()) + if(!_servant) + { + ObjectNotExistException ex(__FILE__, __LINE__); + ex.id = _current.id; + throw ex; + } + + if(!_current.facet.empty()) { _facetServant = _servant->ice_findFacetPath(_current.facet, 0); if(!_facetServant) @@ -59,16 +68,19 @@ IceInternal::Direct::Direct(const Current& current) : { if(_locator && _servant) { - _locator->finished(_current, _servant, _cookie); + try + { + _locator->finished(_current, _servant, _cookie); + } + catch(...) + { + dynamic_cast<ObjectAdapterI*>(_current.adapter.get())->decUsageCount(); + throw; + } } - throw; - } - if(!_servant) - { - ObjectNotExistException ex(__FILE__, __LINE__); - ex.id = _current.id; - throw ex; + dynamic_cast<ObjectAdapterI*>(_current.adapter.get())->decUsageCount(); + throw; } } @@ -76,8 +88,18 @@ IceInternal::Direct::~Direct() { if(_locator && _servant) { - _locator->finished(_current, _servant, _cookie); + try + { + _locator->finished(_current, _servant, _cookie); + } + catch(...) + { + dynamic_cast<ObjectAdapterI*>(_current.adapter.get())->decUsageCount(); + throw; + } } + + dynamic_cast<ObjectAdapterI*>(_current.adapter.get())->decUsageCount(); } const ObjectPtr& diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp index fe16488409e..170d9084c12 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -33,24 +33,36 @@ Ice::LocalException::LocalException(const char* file, int line) : } void -Ice::UnknownLocalException::ice_print(ostream& out) const +Ice::UnknownException::ice_print(ostream& out) const { Exception::ice_print(out); - out << ":\nunknown local exception"; + out << ":\nunknown exception"; + if(!unknown.empty()) + { + out << "\nunknown exception text:\n" << unknown; + } } void -Ice::UnknownUserException::ice_print(ostream& out) const +Ice::UnknownLocalException::ice_print(ostream& out) const { Exception::ice_print(out); - out << ":\nunknown user exception"; + out << ":\nunknown local exception"; + if(!unknown.empty()) + { + out << "\nunknown local exception text:\n" << unknown; + } } void -Ice::UnknownException::ice_print(ostream& out) const +Ice::UnknownUserException::ice_print(ostream& out) const { Exception::ice_print(out); - out << ":\nunknown C++ exception"; + out << ":\nunknown user exception"; + if(!unknown.empty()) + { + out << "\nunknown user exception text:\n" << unknown; + } } void diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 8e6458aae69..ad6063d2138 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -9,7 +9,7 @@ // ********************************************************************** #include <Ice/Incoming.h> -#include <Ice/ObjectAdapter.h> +#include <Ice/ObjectAdapterI.h> // We need ObjectAdapterI, not ObjectAdapter, because of inc/decUsageCount(). #include <Ice/ServantLocator.h> #include <Ice/Object.h> #include <Ice/LocalException.h> @@ -19,23 +19,30 @@ using namespace Ice; using namespace IceInternal; IceInternal::Incoming::Incoming(const InstancePtr& instance, const ObjectAdapterPtr& adapter) : - _adapter(adapter), _is(instance), _os(instance) { + _current.adapter = adapter; + dynamic_cast<ObjectAdapterI*>(_current.adapter.get())->incUsageCount(); +} + +IceInternal::Incoming::~Incoming() +{ + dynamic_cast<ObjectAdapterI*>(_current.adapter.get())->decUsageCount(); } void IceInternal::Incoming::invoke(bool response) { - Current current; - current.adapter = _adapter; - current.id.__read(&_is); - _is.read(current.facet); - _is.read(current.operation); + // + // Read the current. + // + _current.id.__read(&_is); + _is.read(_current.facet); + _is.read(_current.operation); Byte b; _is.read(b); - current.mode = static_cast<OperationMode>(b); + _current.mode = static_cast<OperationMode>(b); Int sz; _is.readSize(sz); while(sz--) @@ -43,121 +50,94 @@ IceInternal::Incoming::invoke(bool response) pair<string, string> pr; _is.read(pr.first); _is.read(pr.second); - current.ctx.insert(current.ctx.end(), pr); + _current.ctx.insert(_current.ctx.end(), pr); } - BasicStream::Container::size_type statusPos = 0; // Initialize, to keep the compiler happy. + _is.startReadEncaps(); + + BasicStream::Container::size_type statusPos; if(response) { statusPos = _os.b.size(); _os.write(static_cast<Byte>(0)); + _os.startWriteEncaps(); } - - // - // Input and output parameters are always sent in an - // encapsulation, which makes it possible to forward requests as - // blobs. - // - _is.startReadEncaps(); - if(response) + else { - _os.startWriteEncaps(); + statusPos = 0; // Initialize, to keep the compiler happy. } ObjectPtr servant; ServantLocatorPtr locator; LocalObjectPtr cookie; - + DispatchStatus status; + + // + // Don't put the code above into the try block below. Exceptions + // in the code above are considered fatal, and must propagate to + // the caller of this operation. + // + try { - if(_adapter) + servant = _current.adapter->identityToServant(_current.id); + + if(!servant && !_current.id.category.empty()) { - servant = _adapter->identityToServant(current.id); - - if(!servant && !current.id.category.empty()) + locator = _current.adapter->findServantLocator(_current.id.category); + if(locator) { - locator = _adapter->findServantLocator(current.id.category); - if(locator) - { - servant = locator->locate(current, cookie); - } + servant = locator->locate(_current, cookie); } - - if(!servant) + } + + if(!servant) + { + locator = _current.adapter->findServantLocator(""); + if(locator) { - locator = _adapter->findServantLocator(""); - if(locator) - { - servant = locator->locate(current, cookie); - } + servant = locator->locate(_current, cookie); } } - DispatchStatus status; - if(!servant) { status = DispatchObjectNotExist; } else { - if(!current.facet.empty()) + if(!_current.facet.empty()) { - ObjectPtr facetServant = servant->ice_findFacetPath(current.facet, 0); + ObjectPtr facetServant = servant->ice_findFacetPath(_current.facet, 0); if(!facetServant) { status = DispatchFacetNotExist; } else { - status = facetServant->__dispatch(*this, current); + status = facetServant->__dispatch(*this, _current); } } else { - status = servant->__dispatch(*this, current); + status = servant->__dispatch(*this, _current); } } if(locator && servant) { - assert(_adapter); - locator->finished(current, servant, cookie); - } - - _is.endReadEncaps(); - if(response) - { - _os.endWriteEncaps(); - - if(status != DispatchOK && status != DispatchUserException) - { - assert(status == DispatchObjectNotExist || - status == DispatchFacetNotExist || - status == DispatchOperationNotExist); - - _os.b.resize(statusPos); - _os.write(static_cast<Byte>(status)); - - current.id.__write(&_os); - _os.write(current.facet); - _os.write(current.operation); - } - else - { - *(_os.b.begin() + statusPos) = static_cast<Byte>(status); - } + locator->finished(_current, servant, cookie); } } catch(const LocationForward& ex) { if(locator && servant) { - assert(_adapter); - locator->finished(current, servant, cookie); + locator->finished(_current, servant, cookie); } _is.endReadEncaps(); + if(response) { _os.endWriteEncaps(); @@ -165,16 +145,18 @@ IceInternal::Incoming::invoke(bool response) _os.write(static_cast<Byte>(DispatchLocationForward)); _os.write(ex._prx); } + + return; } catch(const RequestFailedException& ex) { if(locator && servant) { - assert(_adapter); - locator->finished(current, servant, cookie); + locator->finished(_current, servant, cookie); } _is.endReadEncaps(); + if(response) { _os.endWriteEncaps(); @@ -195,77 +177,130 @@ IceInternal::Incoming::invoke(bool response) { assert(false); } - - // Not current.id.__write(_os), so that the identity - // can be overwritten. + // Write the data from the exception, not from _current, + // so that a RequestFailedException can override the + // information from _current. ex.id.__write(&_os); - // Not _os.write(current.facet), so that the facet can - // be overwritten. _os.write(ex.facet); - // Not _os.write(current.operation), so that the operation - // can be overwritten. _os.write(ex.operation); } - // Rethrow, so that the caller can print a warning. - ex.ice_throw(); + return; } catch(const LocalException& ex) { if(locator && servant) { - assert(_adapter); - locator->finished(current, servant, cookie); + locator->finished(_current, servant, cookie); } _is.endReadEncaps(); + if(response) { _os.endWriteEncaps(); _os.b.resize(statusPos); _os.write(static_cast<Byte>(DispatchUnknownLocalException)); + ostringstream str; + str << ex; + _os.write(str.str()); } - // Rethrow, so that the caller can print a warning. - ex.ice_throw(); + return; } catch(const UserException& ex) { if(locator && servant) { - assert(_adapter); - locator->finished(current, servant, cookie); + locator->finished(_current, servant, cookie); } _is.endReadEncaps(); + if(response) { _os.endWriteEncaps(); _os.b.resize(statusPos); _os.write(static_cast<Byte>(DispatchUnknownUserException)); + ostringstream str; + str << ex; + _os.write(str.str()); } - // Rethrow, so that the caller can print a warning. - ex.ice_throw(); + return; + } + catch(const std::exception& ex) + { + if(locator && servant) + { + locator->finished(_current, servant, cookie); + } + + _is.endReadEncaps(); + + if(response) + { + _os.endWriteEncaps(); + _os.b.resize(statusPos); + _os.write(static_cast<Byte>(DispatchUnknownException)); + ostringstream str; + str << "std::exception: " << ex.what(); + _os.write(str.str()); + } + + return; } catch(...) { if(locator && servant) { - assert(_adapter); - locator->finished(current, servant, cookie); + locator->finished(_current, servant, cookie); } _is.endReadEncaps(); + if(response) { _os.endWriteEncaps(); _os.b.resize(statusPos); _os.write(static_cast<Byte>(DispatchUnknownException)); + string reason = "unknown c++ exception"; + _os.write(reason); } - // Rethrow, so that the caller can print a warning. - throw; + return; + } + + + // + // Don't put the code below into the try block above. Exceptions + // in the code below are considered fatal, and must propagate to + // the caller of this operation. + // + + _is.endReadEncaps(); + + if(response) + { + _os.endWriteEncaps(); + + if(status != DispatchOK && status != DispatchUserException) + { + assert(status == DispatchObjectNotExist || + status == DispatchFacetNotExist || + status == DispatchOperationNotExist); + + _os.b.resize(statusPos); + _os.write(static_cast<Byte>(status)); + + _current.id.__write(&_os); + _os.write(_current.facet); + _os.write(_current.operation); + } + else + { + *(_os.b.begin() + statusPos) = static_cast<Byte>(status); + } } } diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index e227e2c7566..e4737e66e7f 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -39,7 +39,7 @@ using namespace IceInternal; CommunicatorPtr Ice::ObjectAdapterI::getCommunicator() { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -52,7 +52,7 @@ Ice::ObjectAdapterI::getCommunicator() void Ice::ObjectAdapterI::activate() { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -108,7 +108,7 @@ Ice::ObjectAdapterI::activate() void Ice::ObjectAdapterI::hold() { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -122,57 +122,50 @@ Ice::ObjectAdapterI::hold() void Ice::ObjectAdapterI::deactivate() { - IceUtil::Mutex::Lock sync(*this); - - if(!_instance) { - // - // Ignore deactivation requests if the Object Adapter has - // already been deactivated. - // - return; - } + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(), - Ice::voidMemFun(&IncomingConnectionFactory::destroy)); - - // - // Don't do a _incomingConnectionFactories.clear()! - // _incomingConnectionFactories is immutable. Even if all elements - // are destroyed, the elements are still needed by - // waitForDeactivate(). - // - - _instance->outgoingConnectionFactory()->removeAdapter(this); + if(!_instance) + { + // + // Ignore deactivation requests if the Object Adapter has + // already been deactivated. + // + return; + } - _activeServantMap.clear(); - _activeServantMapHint = _activeServantMap.end(); + for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(), + Ice::voidMemFun(&IncomingConnectionFactory::destroy)); + _incomingConnectionFactories.clear(); - for_each(_locatorMap.begin(), _locatorMap.end(), - Ice::secondVoidMemFun<string, ServantLocator>(&ServantLocator::deactivate)); - _locatorMap.clear(); - _locatorMapHint = _locatorMap.end(); + _instance->outgoingConnectionFactory()->removeAdapter(this); - _instance = 0; - _communicator = 0; + _instance = 0; + _communicator = 0; + } + + decUsageCount(); } void Ice::ObjectAdapterI::waitForDeactivate() { - // - // _incommingConnectionFactories is immutable, thus no mutex lock - // is necessary. (A mutex lock wouldn't work here anyway, as there - // would be a deadlock with upcalls.) - // - for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(), - Ice::constVoidMemFun(&IncomingConnectionFactory::waitUntilFinished)); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + + assert(_usageCount >= 0); + + while(_usageCount > 0) + { + wait(); + } + + assert(_usageCount == 0); } ObjectPrx Ice::ObjectAdapterI::add(const ObjectPtr& object, const Identity& ident) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -187,7 +180,7 @@ Ice::ObjectAdapterI::add(const ObjectPtr& object, const Identity& ident) ObjectPrx Ice::ObjectAdapterI::addWithUUID(const ObjectPtr& object) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -205,7 +198,7 @@ Ice::ObjectAdapterI::addWithUUID(const ObjectPtr& object) void Ice::ObjectAdapterI::remove(const Identity& ident) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -219,7 +212,7 @@ Ice::ObjectAdapterI::remove(const Identity& ident) void Ice::ObjectAdapterI::addServantLocator(const ServantLocatorPtr& locator, const string& prefix) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -232,7 +225,7 @@ Ice::ObjectAdapterI::addServantLocator(const ServantLocatorPtr& locator, const s void Ice::ObjectAdapterI::removeServantLocator(const string& prefix) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -273,7 +266,7 @@ Ice::ObjectAdapterI::removeServantLocator(const string& prefix) ServantLocatorPtr Ice::ObjectAdapterI::findServantLocator(const string& prefix) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -309,7 +302,7 @@ Ice::ObjectAdapterI::findServantLocator(const string& prefix) ObjectPtr Ice::ObjectAdapterI::identityToServant(const Identity& ident) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(_activeServantMapHint != _activeServantMap.end()) { @@ -341,7 +334,7 @@ Ice::ObjectAdapterI::proxyToServant(const ObjectPrx& proxy) ObjectPrx Ice::ObjectAdapterI::createProxy(const Identity& ident) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -354,7 +347,7 @@ Ice::ObjectAdapterI::createProxy(const Identity& ident) ObjectPrx Ice::ObjectAdapterI::createDirectProxy(const Identity& ident) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -367,7 +360,7 @@ Ice::ObjectAdapterI::createDirectProxy(const Identity& ident) ObjectPrx Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -386,7 +379,7 @@ Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) void Ice::ObjectAdapterI::addRouter(const RouterPrx& router) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -429,7 +422,7 @@ Ice::ObjectAdapterI::addRouter(const RouterPrx& router) void Ice::ObjectAdapterI::setLocator(const LocatorPrx& locator) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(!_instance) { @@ -442,10 +435,13 @@ Ice::ObjectAdapterI::setLocator(const LocatorPrx& locator) list<ConnectionPtr> Ice::ObjectAdapterI::getIncomingConnections() const { - // - // _incommingConnectionFactories is immutable, thus no mutex lock - // is necessary. - // + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + + if(!_instance) + { + throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); + } + list<ConnectionPtr> connections; vector<IncomingConnectionFactoryPtr>::const_iterator p; for(p = _incomingConnectionFactories.begin(); p != _incomingConnectionFactories.end(); ++p) @@ -456,6 +452,46 @@ Ice::ObjectAdapterI::getIncomingConnections() const return connections; } +void +Ice::ObjectAdapterI::incUsageCount() +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + + if(!_instance) + { + throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); + } + + assert(_usageCount >= 0); + ++_usageCount; +} + +void +Ice::ObjectAdapterI::decUsageCount() +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + + // + // The object adapter may already be deactivated when the usage + // count is decremented, thus no check for prior deactivation. + // + + assert(_usageCount > 0); + --_usageCount; + if(_usageCount == 0) + { + _activeServantMap.clear(); + _activeServantMapHint = _activeServantMap.end(); + + for_each(_locatorMap.begin(), _locatorMap.end(), + Ice::secondVoidMemFun<string, ServantLocator>(&ServantLocator::deactivate)); + _locatorMap.clear(); + _locatorMapHint = _locatorMap.end(); + + notify(); + } +} + Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const CommunicatorPtr& communicator, const string& name, const string& endpts, const string& id) : _instance(instance), @@ -464,7 +500,8 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica _name(name), _id(id), _activeServantMapHint(_activeServantMap.end()), - _locatorMapHint(_locatorMap.end()) + _locatorMapHint(_locatorMap.end()), + _usageCount(1) { string s(endpts); transform(s.begin(), s.end(), s.begin(), ::tolower); @@ -516,22 +553,12 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica throw; } __setNoDelete(false); - -// -// Object Adapters without incoming connection factories are -// permissible, as such Object Adapters can still be used with a -// router. (See addRouter.) -// -/* - if(_incomingConnectionFactories.empty()) - { - throw EndpointParseException(__FILE__, __LINE__); - } -*/ } Ice::ObjectAdapterI::~ObjectAdapterI() { + assert(_usageCount == 0); + if(_instance) { Warning out(_instance->logger()); diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h index f7a6dc565b6..dd686cde2f0 100644 --- a/cpp/src/Ice/ObjectAdapterI.h +++ b/cpp/src/Ice/ObjectAdapterI.h @@ -31,7 +31,7 @@ namespace Ice class ObjectAdapterI; typedef IceUtil::Handle<ObjectAdapterI> ObjectAdapterIPtr; -class ObjectAdapterI : public ObjectAdapter, public ::IceUtil::Mutex +class ObjectAdapterI : public ObjectAdapter, public ::IceUtil::Monitor< ::IceUtil::Mutex> { public: @@ -62,6 +62,8 @@ public: virtual void setLocator(const LocatorPrx&); std::list< ::IceInternal::ConnectionPtr> getIncomingConnections() const; + void incUsageCount(); + void decUsageCount(); private: @@ -87,6 +89,7 @@ private: std::vector< ::IceInternal::EndpointPtr> _routerEndpoints; IceUtil::Mutex _routerEndpointsMutex; ::IceInternal::LocatorInfoPtr _locatorInfo; + int _usageCount; }; } diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index dd207ca36f7..60f99669911 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -251,8 +251,9 @@ IceInternal::Outgoing::finished(BasicStream& is) case DispatchOperationNotExist: { _state = StateLocalException; - // Don't do _is.read(ex->facet), as this operation - // might throw exceptions. In such case ex would leak. + // Don't read the exception members directly into the + // exception. Otherwise if reading fails and raises an + // exception, you will have a memory leak. Identity ident; ident.__read(&_is); vector<string> facet; @@ -292,28 +293,50 @@ IceInternal::Outgoing::finished(BasicStream& is) ex->facet = facet; ex->operation = operation; _exception = auto_ptr<LocalException>(ex); - break; } + case DispatchUnknownException: case DispatchUnknownLocalException: - { - _state = StateLocalException; - _exception = auto_ptr<LocalException>(new UnknownLocalException(__FILE__, __LINE__)); - break; - } - case DispatchUnknownUserException: { _state = StateLocalException; - _exception = auto_ptr<LocalException>(new UnknownUserException(__FILE__, __LINE__)); - break; - } - - case DispatchUnknownException: - { - _state = StateLocalException; - _exception = auto_ptr<LocalException>(new UnknownException(__FILE__, __LINE__)); + // Don't read the exception members directly into the + // exception. Otherwise if reading fails and raises an + // exception, you will have a memory leak. + string unknown; + _is.read(unknown); + + UnknownException* ex; + switch(static_cast<DispatchStatus>(status)) + { + case DispatchUnknownException: + { + ex = new UnknownException(__FILE__, __LINE__); + break; + } + + case DispatchUnknownLocalException: + { + ex = new UnknownLocalException(__FILE__, __LINE__); + break; + } + + case DispatchUnknownUserException: + { + ex = new UnknownUserException(__FILE__, __LINE__); + break; + } + + default: + { + assert(false); + break; + } + } + + ex->unknown = unknown; + _exception = auto_ptr<LocalException>(ex); break; } diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 1875bf99847..27c0ad62d6a 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -731,7 +731,7 @@ IceDelegateM::Ice::Object::~Object() { if(__connection) { - __connection->decProxyUsageCount(); + __connection->decUsageCount(); } } @@ -851,12 +851,12 @@ IceDelegateM::Ice::Object::__copyFrom(const ::IceInternal::Handle< ::IceDelegate if(from->__connection) { - from->__connection->incProxyUsageCount(); + from->__connection->incUsageCount(); } if(__connection) { - __connection->decProxyUsageCount(); + __connection->decUsageCount(); } __connection = from->__connection; @@ -902,7 +902,7 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& ref) } assert(p != connections.end()); __connection = *p; - __connection->incProxyUsageCount(); + __connection->incUsageCount(); } else { @@ -940,7 +940,7 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& ref) OutgoingConnectionFactoryPtr factory = __reference->instance->outgoingConnectionFactory(); __connection = factory->create(filteredEndpoints); assert(__connection); - __connection->incProxyUsageCount(); + __connection->incUsageCount(); } catch(const LocalException& ex) { @@ -1051,22 +1051,7 @@ IceDelegateD::Ice::Object::ice_isA(const string& __id, const Context& __context) while(true) { Direct __direct(__current); - try - { - return __direct.facetServant()->ice_isA(__id, __current); - } - catch(const LocalException&) - { - throw UnknownLocalException(__FILE__, __LINE__); - } - catch(const UserException&) - { - throw UnknownUserException(__FILE__, __LINE__); - } - catch (...) - { - throw UnknownException(__FILE__, __LINE__); - } + return __direct.facetServant()->ice_isA(__id, __current); } return false; // To keep VC++ compiler happy. } @@ -1079,23 +1064,8 @@ IceDelegateD::Ice::Object::ice_ping(const ::Ice::Context& __context) while(true) { Direct __direct(__current); - try - { - __direct.facetServant()->ice_ping(__current); - return; - } - catch(const LocalException&) - { - throw UnknownLocalException(__FILE__, __LINE__); - } - catch(const UserException&) - { - throw UnknownUserException(__FILE__, __LINE__); - } - catch (...) - { - throw UnknownException(__FILE__, __LINE__); - } + __direct.facetServant()->ice_ping(__current); + return; } } @@ -1107,22 +1077,7 @@ IceDelegateD::Ice::Object::ice_ids(const ::Ice::Context& __context) while(true) { Direct __direct(__current); - try - { - return __direct.facetServant()->ice_ids(__current); - } - catch(const LocalException&) - { - throw UnknownLocalException(__FILE__, __LINE__); - } - catch(const UserException&) - { - throw UnknownUserException(__FILE__, __LINE__); - } - catch (...) - { - throw UnknownException(__FILE__, __LINE__); - } + return __direct.facetServant()->ice_ids(__current); } return vector<string>(); // To keep VC++ compiler happy. } @@ -1135,22 +1090,7 @@ IceDelegateD::Ice::Object::ice_id(const ::Ice::Context& __context) while(true) { Direct __direct(__current); - try - { - return __direct.facetServant()->ice_id(__current); - } - catch(const LocalException&) - { - throw UnknownLocalException(__FILE__, __LINE__); - } - catch(const UserException&) - { - throw UnknownUserException(__FILE__, __LINE__); - } - catch (...) - { - throw UnknownException(__FILE__, __LINE__); - } + return __direct.facetServant()->ice_id(__current); } return false; // To keep VC++ compiler happy. } @@ -1163,22 +1103,7 @@ IceDelegateD::Ice::Object::ice_facets(const ::Ice::Context& __context) while(true) { Direct __direct(__current); - try - { - return __direct.facetServant()->ice_facets(__current); - } - catch(const LocalException&) - { - throw UnknownLocalException(__FILE__, __LINE__); - } - catch(const UserException&) - { - throw UnknownUserException(__FILE__, __LINE__); - } - catch (...) - { - throw UnknownException(__FILE__, __LINE__); - } + return __direct.facetServant()->ice_facets(__current); } return vector<string>(); // To keep VC++ compiler happy. } @@ -1202,22 +1127,7 @@ IceDelegateD::Ice::Object::ice_invoke(const string& operation, ex.operation = current.operation; throw ex; } - try - { - return __servant->ice_invoke(inParams, outParams, current); - } - catch(const LocalException&) - { - throw UnknownLocalException(__FILE__, __LINE__); - } - catch(const UserException&) - { - throw UnknownUserException(__FILE__, __LINE__); - } - catch (...) - { - throw UnknownException(__FILE__, __LINE__); - } + return __servant->ice_invoke(inParams, outParams, current); } return false; // To keep VC++ compiler happy. } diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index a8a7b59b0ef..7d1bb70d69d 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -609,7 +609,7 @@ IceInternal::ThreadPool::EventHandlerThread::run() Error out(_pool->_instance->logger()); out << "exception in thread pool:\n" << ex; } - catch (...) + catch(...) { Error out(_pool->_instance->logger()); out << "unknown exception in thread pool"; diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp index 884e88b87d6..b5084a296fe 100644 --- a/cpp/src/Ice/TraceUtil.cpp +++ b/cpp/src/Ice/TraceUtil.cpp @@ -23,17 +23,73 @@ using namespace Ice; using namespace IceInternal; static void +printIdentityFacetOperation(ostream& s, BasicStream& stream) +{ + Identity identity; + identity.__read(&stream); + s << "\nidentity = " << identity; + + vector<string> facet; + stream.read(facet); + s << "\nfacet = "; + vector<string>::const_iterator p = facet.begin(); + while(p != facet.end()) + { + // + // TODO: Escape for whitespace and slashes. + // + s << *p++; + if(p != facet.end()) + { + s << '/'; + } + } + + string operation; + stream.read(operation); + s << "\noperation = " << operation; +} + +static void +printRequestHeader(ostream& s, BasicStream& stream) +{ + printIdentityFacetOperation(s, stream); + + bool idempotent; + stream.read(idempotent); + s << "\nidempotent = " << (idempotent ? "true" : "false"); + + Int sz; + stream.readSize(sz); + s << "\ncontext = "; + while(sz--) + { + pair<string, string> pair; + stream.read(pair.first); + stream.read(pair.second); + s << pair.first << '/' << pair.second; + if(sz) + { + s << ", "; + } + } +} + +static void printHeader(ostream& s, BasicStream& stream) { Byte protVer; stream.read(protVer); // s << "\nprotocol version = " << static_cast<int>(protVer); + Byte encVer; stream.read(encVer); // s << "\nencoding version = " << static_cast<int>(encVer); + Byte type; stream.read(type); s << "\nmessage type = " << static_cast<int>(type) << ' '; + switch(type) { case requestMsg: @@ -41,36 +97,43 @@ printHeader(ostream& s, BasicStream& stream) s << "(request)"; break; } + case requestBatchMsg: { s << "(batch request)"; break; } + case replyMsg: { s << "(reply)"; break; } + case compressedRequestMsg: { s << "(compressed request)"; break; } + case compressedRequestBatchMsg: { s << "(compressed batch request)"; break; } + case compressedReplyMsg: { s << "(compressed reply)"; break; } + case closeConnectionMsg: { s << "(close connection)"; break; } + case validateConnectionMsg: { s << "(validate connection)"; @@ -82,115 +145,12 @@ printHeader(ostream& s, BasicStream& stream) break; } } + Int size; stream.read(size); s << "\nmessage size = " << size; } -static void -printRequestHeader(ostream& s, BasicStream& stream) -{ - Identity identity; - identity.__read(&stream); - s << "\nidentity = " << identity; - vector<string> facet; - stream.read(facet); - s << "\nfacet = "; - vector<string>::const_iterator p = facet.begin(); - while(p != facet.end()) - { - // - // TODO: Escape for whitespace and slashes. - // - s << *p++; - if(p != facet.end()) - { - s << '/'; - } - } - string operation; - stream.read(operation); - s << "\noperation = " << operation; - bool idempotent; - stream.read(idempotent); - s << "\nidempotent = " << (idempotent ? "true" : "false"); - Int sz; - stream.readSize(sz); - s << "\ncontext = "; - while(sz--) - { - pair<string, string> pair; - stream.read(pair.first); - stream.read(pair.second); - s << pair.first << '/' << pair.second; - if(sz) - { - s << ", "; - } - } -} - -#if 0 -static void -dumpOctets(const char* cat, const BasicStream& stream, const ::Ice::LoggerPtr& logger) -{ - ostringstream s; - s << endl; - - const BasicStream::Container::size_type inc = 8; - - for(BasicStream::Container::size_type i = 0; i < stream.b.size(); i += inc) - { - for(BasicStream::Container::size_type j = i; j - i < inc; j++) - { - if(j < stream.b.size()) - { - int n = stream.b[j]; - if(n < 0) - { - n += 256; - } - if(n < 10) - { - s << " " << n; - } - else if(n < 100) - { - s << " " << n; - } - else - { - s << n; - } - s << " "; - } - else - { - s << " "; - } - } - - s << '"'; - - for(BasicStream::Container::size_type j = i; j < stream.b.size() && j - i < inc; j++) - { - if(stream.b[j] >= 32 && stream.b[j] < 127) - { - s << (char)stream.b[j]; - } - else - { - s << '.'; - } - } - - s << '"' << endl; - } - - logger->trace(cat, s.str()); -} -#endif - void IceInternal::traceHeader(const char* heading, const BasicStream& str, const ::Ice::LoggerPtr& logger, const TraceLevelsPtr& tl) @@ -200,9 +160,11 @@ IceInternal::traceHeader(const char* heading, const BasicStream& str, const ::Ic BasicStream& stream = const_cast<BasicStream&>(str); BasicStream::Container::iterator p = stream.i; stream.i = stream.b.begin(); + ostringstream s; s << heading; printHeader(s, stream); + logger->trace(tl->protocolCat, s.str()); stream.i = p; } @@ -217,9 +179,11 @@ IceInternal::traceRequest(const char* heading, const BasicStream& str, const ::I BasicStream& stream = const_cast<BasicStream&>(str); BasicStream::Container::iterator p = stream.i; stream.i = stream.b.begin(); + ostringstream s; s << heading; printHeader(s, stream); + Int requestId; stream.read(requestId); s << "\nrequest id = " << requestId; @@ -228,6 +192,7 @@ IceInternal::traceRequest(const char* heading, const BasicStream& str, const ::I s << " (oneway)"; } printRequestHeader(s, stream); + logger->trace(tl->protocolCat, s.str()); stream.i = p; } @@ -242,9 +207,11 @@ IceInternal::traceBatchRequest(const char* heading, const BasicStream& str, cons BasicStream& stream = const_cast<BasicStream&>(str); BasicStream::Container::iterator p = stream.i; stream.i = stream.b.begin(); + ostringstream s; s << heading; printHeader(s, stream); + int cnt = 0; while(stream.i != stream.b.end()) { @@ -252,6 +219,7 @@ IceInternal::traceBatchRequest(const char* heading, const BasicStream& str, cons printRequestHeader(s, stream); stream.skipEncaps(); } + logger->trace(tl->protocolCat, s.str()); stream.i = p; } @@ -266,12 +234,15 @@ IceInternal::traceReply(const char* heading, const BasicStream& str, const ::Ice BasicStream& stream = const_cast<BasicStream&>(str); BasicStream::Container::iterator p = stream.i; stream.i = stream.b.begin(); + ostringstream s; s << heading; printHeader(s, stream); + Int requestId; stream.read(requestId); s << "\nrequest id = " << requestId; + Byte status; stream.read(status); s << "\nreply status = " << static_cast<int>(status) << ' '; @@ -282,52 +253,98 @@ IceInternal::traceReply(const char* heading, const BasicStream& str, const ::Ice s << "(ok)"; break; } + case DispatchUserException: { s << "(user exception)"; break; } + case DispatchLocationForward: { s << "(location forward)"; break; } + case DispatchObjectNotExist: - { - s << "(object not exist)"; - break; - } case DispatchFacetNotExist: - { - s << "(facet not exist)"; - break; - } case DispatchOperationNotExist: { - s << "(operation not exist)"; + switch(static_cast<DispatchStatus>(status)) + { + case DispatchObjectNotExist: + { + s << "(object not exist)"; + break; + } + + case DispatchFacetNotExist: + { + s << "(facet not exist)"; + break; + } + + case DispatchOperationNotExist: + { + s << "(operation not exist)"; + break; + } + + default: + { + assert(false); + break; + } + } + + printIdentityFacetOperation(s, stream); break; } + + case DispatchUnknownException: case DispatchUnknownLocalException: - { - s << "(unknown local exception)"; - break; - } case DispatchUnknownUserException: { - s << "(unknown user exception)"; - break; - } - case DispatchUnknownException: - { - s << "(unknown exception)"; + switch(static_cast<DispatchStatus>(status)) + { + case DispatchUnknownException: + { + s << "(unknown exception)"; + break; + } + + case DispatchUnknownLocalException: + { + s << "(unknown local exception)"; + break; + } + + case DispatchUnknownUserException: + { + s << "(unknown user exception)"; + break; + } + + default: + { + assert(false); + break; + } + } + + string unknown; + stream.read(unknown); + s << "\nunknown = " << unknown; break; } + default: { s << "(unknown)"; break; } } + logger->trace(tl->protocolCat, s.str()); stream.i = p; } diff --git a/cpp/src/IceSSL/RSACertificateGen.cpp b/cpp/src/IceSSL/RSACertificateGen.cpp index 600b4e386e4..d3edd8b21cf 100644 --- a/cpp/src/IceSSL/RSACertificateGen.cpp +++ b/cpp/src/IceSSL/RSACertificateGen.cpp @@ -22,6 +22,17 @@ using std::string; using std::back_inserter; +IceSSL::RSACertificateGenContext::RSACertificateGenContext() : + _modulusLength(0), + _secondsValid(0), + _issuedAdjustment(0) +{ +} + +IceSSL::RSACertificateGenContext::~RSACertificateGenContext() +{ +} + long IceSSL::RSACertificateGenContext::minutesToSeconds(long minutes) { @@ -52,17 +63,6 @@ IceSSL::RSACertificateGenContext::yearsToSeconds(long years) return weeksToSeconds(years * 365L); } -IceSSL::RSACertificateGenContext::RSACertificateGenContext() : - _modulusLength(0), - _secondsValid(0), - _issuedAdjustment(0) -{ -} - -IceSSL::RSACertificateGenContext::~RSACertificateGenContext() -{ -} - void IceSSL::RSACertificateGenContext::setCountry(const string& country) { @@ -158,7 +158,7 @@ IceSSL::RSACertificateGenContext::getOrganization() const } unsigned char* -IceSSL::RSACertificateGenContext::getOrgainizationalUnit() const +IceSSL::RSACertificateGenContext::getOrganizationalUnit() const { unsigned char* orgUnit = reinterpret_cast<unsigned char *>(const_cast<char*>(_organizationalUnit.c_str())); @@ -248,12 +248,12 @@ IceSSL::RSACertificateGen::generate(const RSACertificateGenContext& context) X509_gmtime_adj(X509_get_notAfter(x509SelfSigned), context.getSecondsValid()); // Set up subject/issuer Distinguished Name (DN). - X509_NAME_add_entry_by_txt(subjectName, "C", MBSTRING_ASC, context.getCountry(), -1, -1, 0); - X509_NAME_add_entry_by_txt(subjectName, "ST", MBSTRING_ASC, context.getStateProvince(), -1, -1, 0); - X509_NAME_add_entry_by_txt(subjectName, "L", MBSTRING_ASC, context.getLocality(), -1, -1, 0); - X509_NAME_add_entry_by_txt(subjectName, "O", MBSTRING_ASC, context.getOrganization(), -1, -1, 0); - X509_NAME_add_entry_by_txt(subjectName, "OU", MBSTRING_ASC, context.getOrgainizationalUnit(), -1, -1, 0); - X509_NAME_add_entry_by_txt(subjectName, "CN", MBSTRING_ASC, context.getCommonName(), -1, -1, 0); + X509_NAME_add_entry_by_txt(subjectName, "C", MBSTRING_ASC, context.getCountry(), -1, -1, 0); + X509_NAME_add_entry_by_txt(subjectName, "ST", MBSTRING_ASC, context.getStateProvince(), -1, -1, 0); + X509_NAME_add_entry_by_txt(subjectName, "L", MBSTRING_ASC, context.getLocality(), -1, -1, 0); + X509_NAME_add_entry_by_txt(subjectName, "O", MBSTRING_ASC, context.getOrganization(), -1, -1, 0); + X509_NAME_add_entry_by_txt(subjectName, "OU", MBSTRING_ASC, context.getOrganizationalUnit(), -1, -1, 0); + X509_NAME_add_entry_by_txt(subjectName, "CN", MBSTRING_ASC, context.getCommonName(), -1, -1, 0); // Self signed - set issuer and subject names identical X509_set_issuer_name(x509SelfSigned, subjectName); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 3d63d543a39..b9a43894ccb 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1737,16 +1737,13 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) C << sb; C << nl << "::IceInternal::Direct __direct(__current);"; string thisPointer = fixKwd(cl->scoped()) + "*"; - C << nl << thisPointer << " __servant = dynamic_cast< " - << thisPointer << ">(__direct.facetServant().get());"; + C << nl << thisPointer << " __servant = dynamic_cast< " << thisPointer << ">(__direct.facetServant().get());"; C << nl << "if(!__servant)"; C << sb; C << nl << "::Ice::OperationNotExistException __opEx(__FILE__, __LINE__);"; C << nl << "__opEx.operation = __current.operation;"; C << nl << "throw __opEx;"; C << eb; - C << nl << "try"; - C << sb; C << nl; if(ret) { @@ -1758,30 +1755,6 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) C << nl << "return;"; } C << eb; - ExceptionList throws = p->throws(); - throws.sort(); - throws.unique(); - ExceptionList::const_iterator r; - for(r = throws.begin(); r != throws.end(); ++r) - { - C << nl << "catch(const " << fixKwd((*r)->scoped()) << "&)"; - C << sb; - C << nl << "throw;"; - C << eb; - } - C << nl << "catch(const ::Ice::UserException&)"; - C << sb; - C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);"; - C << eb; - C << nl << "catch(const ::Ice::LocalException&)"; - C << sb; - C << nl << "throw;"; - C << eb; - C << nl << "catch(...)"; - C << sb; - C << nl << "throw ::Ice::UnknownException(__FILE__, __LINE__);"; - C << eb; - C << eb; C << eb; } |