diff options
Diffstat (limited to 'cpp/src')
32 files changed, 609 insertions, 94 deletions
diff --git a/cpp/src/Glacier2Lib/SessionHelper.cpp b/cpp/src/Glacier2Lib/SessionHelper.cpp index 85c513a7081..bc0f625d503 100644 --- a/cpp/src/Glacier2Lib/SessionHelper.cpp +++ b/cpp/src/Glacier2Lib/SessionHelper.cpp @@ -507,21 +507,40 @@ public: _callback(callback), _session(session) { +#ifdef ICE_CPP11_MAPPING + _ex = ex.ice_clone(); +#else _ex.reset(ex.ice_clone()); +#endif } virtual void run() { +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(_ex); + } + catch(const Ice::Exception& ex) + { + _callback->connectFailed(_session, ex); + } +#else const Ice::Exception* ex(_ex.get()); _callback->connectFailed(_session, *ex); +#endif } private: const Glacier2::SessionCallbackPtr _callback; const Glacier2::SessionHelperPtr _session; +#ifdef ICE_CPP11_MAPPING + std::exception_ptr _ex; +#else IceUtil::UniquePtr<Ice::Exception> _ex; +#endif }; class CreatedCommunicator : public Ice::DispatcherCall diff --git a/cpp/src/Ice/AsyncResult.cpp b/cpp/src/Ice/AsyncResult.cpp index 8eb8c862f1f..5848747810e 100644 --- a/cpp/src/Ice/AsyncResult.cpp +++ b/cpp/src/Ice/AsyncResult.cpp @@ -87,7 +87,7 @@ void AsyncResult::waitForSent() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - while(!(_state & Sent) && !_exception.get()) + while(!(_state & Sent) && !ICE_EXCEPTION_GET(_exception)) { _monitor.wait(); } @@ -97,9 +97,9 @@ void AsyncResult::throwLocalException() const { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { - _exception.get()->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); } } @@ -151,10 +151,12 @@ AsyncResult::__wait() { _monitor.wait(); } - if(_exception.get()) + + if(ICE_EXCEPTION_GET(_exception)) { - _exception.get()->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); } + return _state & OK; } @@ -257,8 +259,7 @@ bool AsyncResult::sent(bool done) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - assert(!_exception.get()); - + assert(!ICE_EXCEPTION_GET(_exception)); bool alreadySent = _state & Sent; _state |= Sent; if(done) @@ -298,7 +299,11 @@ AsyncResult::finished(const Ice::Exception& ex) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); _state |= Done; +#ifdef ICE_CPP11_MAPPING + _exception = ex.ice_clone(); +#else _exception.reset(ex.ice_clone()); +#endif _cancellationHandler = 0; _observer.failed(ex.ice_name()); if(!_callback) @@ -433,7 +438,11 @@ AsyncResult::cancel(const Ice::LocalException& ex) CancellationHandlerPtr handler; { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - _cancellationException.reset(ex.ice_clone()); +#ifdef ICE_CPP11_MAPPING + _cancellationException = ex.ice_clone(); +#else + _cancellationException.reset(ex.ice_clone()); +#endif if(!_cancellationHandler) { return; @@ -451,6 +460,20 @@ void AsyncResult::cancelable(const CancellationHandlerPtr& handler) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); +#ifdef ICE_CPP11_MAPPING + if(_cancellationException) + { + try + { + rethrow_exception(_cancellationException); + } + catch(const Ice::Exception&) + { + _cancellationException = nullptr; + throw; + } + } +#else if(_cancellationException.get()) { try @@ -463,6 +486,7 @@ AsyncResult::cancelable(const CancellationHandlerPtr& handler) throw; } } +#endif _cancellationHandler = handler; } diff --git a/cpp/src/Ice/BatchRequestQueue.cpp b/cpp/src/Ice/BatchRequestQueue.cpp index 4f1c39c234f..9f5d506545b 100644 --- a/cpp/src/Ice/BatchRequestQueue.cpp +++ b/cpp/src/Ice/BatchRequestQueue.cpp @@ -90,11 +90,10 @@ void BatchRequestQueue::prepareBatchRequest(BasicStream* os) { Lock sync(*this); - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { - _exception->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); } - waitStreamInUse(false); _batchStreamInUse = true; _batchStream.swap(*os); @@ -207,7 +206,11 @@ void BatchRequestQueue::destroy(const Ice::LocalException& ex) { Lock sync(*this); +#ifdef ICE_CPP11_MAPPING + _exception = ex.ice_clone(); +#else _exception.reset(ex.ice_clone()); +#endif } bool diff --git a/cpp/src/Ice/BatchRequestQueue.h b/cpp/src/Ice/BatchRequestQueue.h index 359113a7973..64d6bc5f658 100644 --- a/cpp/src/Ice/BatchRequestQueue.h +++ b/cpp/src/Ice/BatchRequestQueue.h @@ -54,7 +54,11 @@ private: bool _batchStreamCanFlush; int _batchRequestNum; size_t _batchMarker; +#ifdef ICE_CPP11_MAPPING + std::exception_ptr _exception; +#else IceUtil::UniquePtr<Ice::LocalException> _exception; +#endif size_t _maxSize; }; diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp index 3818144f279..8bc759f07bb 100644 --- a/cpp/src/Ice/ConnectRequestHandler.cpp +++ b/cpp/src/Ice/ConnectRequestHandler.cpp @@ -94,7 +94,7 @@ ConnectRequestHandler::requestCanceled(OutgoingBase* out, const Ice::LocalExcept { { Lock sync(*this); - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { return; // The request has been notified of a failure already. } @@ -121,7 +121,7 @@ ConnectRequestHandler::asyncRequestCanceled(const OutgoingAsyncBasePtr& outAsync { { Lock sync(*this); - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { return; // The request has been notified of a failure already. } @@ -149,9 +149,9 @@ Ice::ConnectionIPtr ConnectRequestHandler::getConnection() { Lock sync(*this); - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { - _exception->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); return 0; // Keep the compiler happy. } else @@ -164,22 +164,25 @@ Ice::ConnectionIPtr ConnectRequestHandler::waitForConnection() { Lock sync(*this); - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { +#ifdef ICE_CPP11_MAPPING + throw RetryException(_exception); +#else throw RetryException(*_exception.get()); +#endif } - // // Wait for the connection establishment to complete or fail. // - while(!_initialized && !_exception.get()) + while(!_initialized && !ICE_EXCEPTION_GET(_exception)) { wait(); } - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { - _exception->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); return 0; // Keep the compiler happy. } else @@ -193,7 +196,7 @@ ConnectRequestHandler::setConnection(const Ice::ConnectionIPtr& connection, bool { { Lock sync(*this); - assert(!_exception.get() && !_connection); + assert(!ICE_EXCEPTION_GET(_exception) && !_connection); _connection = connection; _compress = compress; } @@ -222,8 +225,12 @@ void ConnectRequestHandler::setException(const Ice::LocalException& ex) { Lock sync(*this); - assert(!_initialized && !_exception.get()); + assert(!_initialized && !ICE_EXCEPTION_GET(_exception)); +#ifdef ICE_CPP11_MAPPING + _exception = ex.ice_clone(); +#else _exception.reset(ex.ice_clone()); +#endif _proxies.clear(); _proxy = 0; // Break cyclic reference count. @@ -242,6 +249,29 @@ ConnectRequestHandler::setException(const Ice::LocalException& ex) // Ignore } +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(_exception); + } + catch(const Ice::LocalException& ex) + { + for(deque<Request>::const_iterator p = _requests.begin(); p != _requests.end(); ++p) + { + if(p->out) + { + p->out->completed(ex); + } + else + { + if(p->outAsync->completed(ex)) + { + p->outAsync->invokeCompletedAsync(); + } + } + } + } +#else for(deque<Request>::const_iterator p = _requests.begin(); p != _requests.end(); ++p) { if(p->out) @@ -256,6 +286,7 @@ ConnectRequestHandler::setException(const Ice::LocalException& ex) } } } +#endif _requests.clear(); notifyAll(); } @@ -282,12 +313,12 @@ ConnectRequestHandler::initialized() } else { - while(_flushing && !_exception.get()) + while(_flushing && !ICE_EXCEPTION_GET(_exception)) { wait(); } - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { if(_connection) { @@ -299,7 +330,7 @@ ConnectRequestHandler::initialized() // return true; } - _exception->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); return false; // Keep the compiler happy. } else @@ -324,7 +355,11 @@ ConnectRequestHandler::flushRequests() _flushing = true; } +#ifdef ICE_CPP11_MAPPING + std::exception_ptr exception; +#else IceUtil::UniquePtr<Ice::LocalException> exception; +#endif while(!_requests.empty()) // _requests is immutable when _flushing = true { Request& req = _requests.front(); @@ -341,10 +376,30 @@ ConnectRequestHandler::flushRequests() } catch(const RetryException& ex) { - exception.reset(ex.get()->ice_clone()); +#ifdef ICE_CPP11_MAPPING + exception = ex.get(); + try + { + rethrow_exception(exception); + } + catch(const Ice::LocalException& ee) + { + // Remove the request handler before retrying. + _reference->getInstance()->requestHandlerFactory()->removeRequestHandler(_reference, shared_from_this()); + if(req.out) + { + req.out->retryException(ee); + } + else + { + req.outAsync->retryException(ee); + } + } +#else + exception.reset(ex.get()->ice_clone()); // Remove the request handler before retrying. - _reference->getInstance()->requestHandlerFactory()->removeRequestHandler(_reference, ICE_SHARED_FROM_THIS); + _reference->getInstance()->requestHandlerFactory()->removeRequestHandler(_reference, this); if(req.out) { @@ -354,10 +409,15 @@ ConnectRequestHandler::flushRequests() { req.outAsync->retryException(*ex.get()); } +#endif } catch(const Ice::LocalException& ex) { +#ifdef ICE_CPP11_MAPPING + exception = ex.ice_clone(); +#else exception.reset(ex.ice_clone()); +#endif if(req.out) { req.out->completed(ex); @@ -376,7 +436,7 @@ ConnectRequestHandler::flushRequests() // request handler to use the more efficient connection request // handler. // - if(_reference->getCacheConnection() && !exception.get()) + if(_reference->getCacheConnection() && !ICE_EXCEPTION_GET(exception)) { _requestHandler = ICE_MAKE_SHARED(ConnectionRequestHandler, _reference, _connection, _compress); for(set<Ice::ObjectPrxPtr>::const_iterator p = _proxies.begin(); p != _proxies.end(); ++p) @@ -388,8 +448,12 @@ ConnectRequestHandler::flushRequests() { Lock sync(*this); assert(!_initialized); +#ifdef ICE_CPP11_MAPPING + swap(_exception, exception); +#else _exception.swap(exception); - _initialized = !_exception.get(); +#endif + _initialized = !ICE_EXCEPTION_GET(_exception); _flushing = false; // @@ -399,7 +463,7 @@ ConnectRequestHandler::flushRequests() _reference->getInstance()->requestHandlerFactory()->removeRequestHandler(_reference, ICE_SHARED_FROM_THIS); _proxies.clear(); - _proxy = 0; // Break cyclic reference count. + _proxy = ICE_NULLPTR; // Break cyclic reference count. notifyAll(); } } diff --git a/cpp/src/Ice/ConnectRequestHandler.h b/cpp/src/Ice/ConnectRequestHandler.h index 1dd13dd5274..e8e3cc52686 100644 --- a/cpp/src/Ice/ConnectRequestHandler.h +++ b/cpp/src/Ice/ConnectRequestHandler.h @@ -74,7 +74,11 @@ private: Ice::ConnectionIPtr _connection; bool _compress; +#ifdef ICE_CPP11_MAPPING + std::exception_ptr _exception; +#else IceUtil::UniquePtr<Ice::LocalException> _exception; +#endif bool _initialized; bool _flushing; diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index ee241cc4c39..d3b54bfa386 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -317,8 +317,8 @@ Ice::ConnectionI::start(const StartCallbackPtr& callback) IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(_state >= StateClosed) // The connection might already be closed if the communicator was destroyed. { - assert(_exception.get()); - _exception->ice_throw(); + assert(ICE_EXCEPTION_GET(_exception)); + ICE_RETHROW_EXCEPTION(_exception); } if(!initialize() || !validate()) @@ -339,8 +339,8 @@ Ice::ConnectionI::start(const StartCallbackPtr& callback) if(_state >= StateClosing) { - assert(_exception.get()); - _exception->ice_throw(); + assert(ICE_EXCEPTION_GET(_exception)); + ICE_RETHROW_EXCEPTION(_exception); } } @@ -354,7 +354,7 @@ Ice::ConnectionI::start(const StartCallbackPtr& callback) exception(ex); if(callback) { - callback->connectionStartFailed(shared_from_this(), *_exception.get()); + callback->connectionStartFailed(shared_from_this(), ex); return; } else @@ -487,10 +487,10 @@ Ice::ConnectionI::throwException() const { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { assert(_state >= StateClosing); - _exception->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); } } @@ -617,14 +617,18 @@ Ice::ConnectionI::sendRequest(OutgoingBase* out, bool compress, bool response, i BasicStream* os = out->os(); IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - if(_exception.get()) + // + // If the connection is closed before we even have a chance + // to send our request, we always try to send the request + // again. + // + if(ICE_EXCEPTION_GET(_exception)) { - // - // If the connection is closed before we even have a chance - // to send our request, we always try to send the request - // again. - // +#ifdef ICE_CPP11_MAPPING + throw RetryException(_exception); +#else throw RetryException(*_exception.get()); +#endif } assert(_state > StateNotValidated); @@ -684,8 +688,8 @@ Ice::ConnectionI::sendRequest(OutgoingBase* out, bool compress, bool response, i catch(const LocalException& ex) { setState(StateClosed, ex); - assert(_exception.get()); - _exception->ice_throw(); + assert(ICE_EXCEPTION_GET(_exception)); + ICE_RETHROW_EXCEPTION(_exception); } if(response) @@ -705,16 +709,19 @@ Ice::ConnectionI::sendAsyncRequest(const OutgoingAsyncBasePtr& out, bool compres BasicStream* os = out->getOs(); IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - if(_exception.get()) + // + // If the exception is closed before we even have a chance + // to send our request, we always try to send the request + // again. + // + if(ICE_EXCEPTION_GET(_exception)) { - // - // If the exception is closed before we even have a chance - // to send our request, we always try to send the request - // again. - // +#ifdef ICE_CPP11_MAPPING + throw RetryException(_exception); +#else throw RetryException(*_exception.get()); +#endif } - assert(_state > StateNotValidated); assert(_state < StateClosing); @@ -773,8 +780,8 @@ Ice::ConnectionI::sendAsyncRequest(const OutgoingAsyncBasePtr& out, bool compres catch(const LocalException& ex) { setState(StateClosed, ex); - assert(_exception.get()); - _exception->ice_throw(); + assert(ICE_EXCEPTION_GET(_exception)); + ICE_RETHROW_EXCEPTION(_exception); } if(response) @@ -1259,8 +1266,8 @@ Ice::ConnectionI::sendResponse(Int, BasicStream* os, Byte compressFlag, bool /*a if(_state >= StateClosed) { - assert(_exception.get()); - _exception->ice_throw(); + assert(ICE_EXCEPTION_GET(_exception)); + ICE_RETHROW_EXCEPTION(_exception); } OutgoingMessage message(os, compressFlag > 0); @@ -1298,8 +1305,8 @@ Ice::ConnectionI::sendNoResponse() if(_state >= StateClosed) { - assert(_exception.get()); - _exception->ice_throw(); + assert(ICE_EXCEPTION_GET(_exception)); + ICE_RETHROW_EXCEPTION(_exception); } if(_state == StateClosing && _dispatchCount == 0) @@ -1957,8 +1964,20 @@ Ice::ConnectionI::finish(bool close) { string verb = _connector ? "establish" : "accept"; Trace out(_instance->initializationData().logger, _instance->traceLevels()->networkCat); +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(_exception); + } + catch(const Ice::Exception& ex) + { + out << "failed to " << verb << " " << _endpoint->protocol() << " connection\n" << toString() + << "\n" << ex; + } +#else out << "failed to " << verb << " " << _endpoint->protocol() << " connection\n" << toString() << "\n" << *_exception.get(); +#endif } } else @@ -1971,6 +1990,23 @@ Ice::ConnectionI::finish(bool close) // // Trace the cause of unexpected connection closures // +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(_exception); + } + catch(const Ice::LocalException& ex) + { + if(!(dynamic_cast<const CloseConnectionException*>(&ex) || + dynamic_cast<const ForcedCloseConnectionException*>(&ex) || + dynamic_cast<const ConnectionTimeoutException*>(&ex) || + dynamic_cast<const CommunicatorDestroyedException*>(&ex) || + dynamic_cast<const ObjectAdapterDeactivatedException*>(&ex))) + { + out << "\n" << ex; + } + } +#else if(!(dynamic_cast<const CloseConnectionException*>(_exception.get()) || dynamic_cast<const ForcedCloseConnectionException*>(_exception.get()) || dynamic_cast<const ConnectionTimeoutException*>(_exception.get()) || @@ -1979,6 +2015,7 @@ Ice::ConnectionI::finish(bool close) { out << "\n" << *_exception.get(); } +#endif } } @@ -1989,7 +2026,18 @@ Ice::ConnectionI::finish(bool close) if(_startCallback) { +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(_exception); + } + catch(const LocalException& ex) + { + _startCallback->connectionStartFailed(shared_from_this(), ex); + } +#else _startCallback->connectionStartFailed(shared_from_this(), *_exception.get()); +#endif _startCallback = 0; } @@ -2029,6 +2077,30 @@ Ice::ConnectionI::finish(bool close) #endif } +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(_exception); + } + catch(const Ice::LocalException& ex) + { + for(deque<OutgoingMessage>::iterator o = _sendStreams.begin(); o != _sendStreams.end(); ++o) + { + o->completed(ex); + if(o->requestId) // Make sure finished isn't called twice. + { + if(o->out) + { + _requests.erase(o->requestId); + } + else + { + _asyncRequests.erase(o->requestId); + } + } + } + } +#else for(deque<OutgoingMessage>::iterator o = _sendStreams.begin(); o != _sendStreams.end(); ++o) { o->completed(*_exception.get()); @@ -2044,13 +2116,38 @@ Ice::ConnectionI::finish(bool close) } } } +#endif _sendStreams.clear(); // Must be cleared before _requests because of Outgoing* references in OutgoingMessage } +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(_exception); + } + catch(const Ice::LocalException& ex) + { + for(map<Int, OutgoingBase*>::const_iterator p = _requests.begin(); p != _requests.end(); ++p) + { + p->second->completed(ex); + } + + _requests.clear(); + + for(map<Int, OutgoingAsyncBasePtr>::const_iterator q = _asyncRequests.begin(); q != _asyncRequests.end(); ++q) + { + if(q->second->completed(ex)) + { + q->second->invokeCompleted(); + } + } + } +#else for(map<Int, OutgoingBase*>::const_iterator p = _requests.begin(); p != _requests.end(); ++p) { p->second->completed(*_exception.get()); } + _requests.clear(); for(map<Int, OutgoingAsyncBasePtr>::const_iterator q = _asyncRequests.begin(); q != _asyncRequests.end(); ++q) @@ -2060,6 +2157,8 @@ Ice::ConnectionI::finish(bool close) q->second->invokeCompleted(); } } +#endif + _asyncRequests.clear(); // @@ -2141,7 +2240,7 @@ Ice::ConnectionI::getInfo() const IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(_state >= StateClosed) { - _exception->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); } return initConnectionInfo(); } @@ -2152,7 +2251,7 @@ Ice::ConnectionI::setBufferSize(Ice::Int rcvSize, Ice::Int sndSize) IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(_state >= StateClosed) { - _exception->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); } _transceiver->setBufferSize(rcvSize, sndSize); _info = 0; // Invalidate the cached connection info @@ -2279,15 +2378,17 @@ Ice::ConnectionI::setState(State state, const LocalException& ex) return; } - if(!_exception.get()) + if(!ICE_EXCEPTION_GET(_exception)) { // // If we are in closed state, an exception must be set. // assert(_state != StateClosed); - +#ifdef ICE_CPP11_MAPPING + _exception = ex.ice_clone(); +#else _exception.reset(ex.ice_clone()); - +#endif // // We don't warn if we are not validated. // @@ -2296,15 +2397,15 @@ Ice::ConnectionI::setState(State state, const LocalException& ex) // // Don't warn about certain expected exceptions. // - if(!(dynamic_cast<const CloseConnectionException*>(_exception.get()) || - dynamic_cast<const ForcedCloseConnectionException*>(_exception.get()) || - dynamic_cast<const ConnectionTimeoutException*>(_exception.get()) || - dynamic_cast<const CommunicatorDestroyedException*>(_exception.get()) || - dynamic_cast<const ObjectAdapterDeactivatedException*>(_exception.get()) || - (dynamic_cast<const ConnectionLostException*>(_exception.get()) && _state >= StateClosing))) + if(!(dynamic_cast<const CloseConnectionException*>(&ex) || + dynamic_cast<const ForcedCloseConnectionException*>(&ex) || + dynamic_cast<const ConnectionTimeoutException*>(&ex) || + dynamic_cast<const CommunicatorDestroyedException*>(&ex) || + dynamic_cast<const ObjectAdapterDeactivatedException*>(&ex) || + (dynamic_cast<const ConnectionLostException*>(&ex) && _state >= StateClosing))) { Warning out(_logger); - out << "connection exception:\n" << *_exception.get() << '\n' << _desc; + out << "connection exception:\n" << ex << '\n' << _desc; } } } @@ -2413,8 +2514,18 @@ Ice::ConnectionI::setState(State state) return; } +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(_exception); + } + catch(const Ice::LocalException& ex) + { + _batchRequestQueue->destroy(ex); + } +#else _batchRequestQueue->destroy(*_exception.get()); - +#endif // // Don't need to close now for connections so only close the transceiver // if the selector request it. @@ -2473,6 +2584,27 @@ Ice::ConnectionI::setState(State state) newState, _observer.get())); } +#ifdef ICE_CPP11_MAPPING + if(_observer && state == StateClosed && _exception) + { + try + { + rethrow_exception(_exception); + } + catch(const Ice::LocalException& ex) + { + if(!(dynamic_cast<const CloseConnectionException*>(&ex) || + dynamic_cast<const ForcedCloseConnectionException*>(&ex) || + dynamic_cast<const ConnectionTimeoutException*>(&ex) || + dynamic_cast<const CommunicatorDestroyedException*>(&ex) || + dynamic_cast<const ObjectAdapterDeactivatedException*>(&ex) || + (dynamic_cast<const ConnectionLostException*>(&ex) && _state >= StateClosing))) + { + _observer->failed(ex.ice_name()); + } + } + } +#else if(_observer && state == StateClosed && _exception.get()) { if(!(dynamic_cast<const CloseConnectionException*>(_exception.get()) || @@ -2485,6 +2617,7 @@ Ice::ConnectionI::setState(State state) _observer->failed(_exception->ice_name()); } } +#endif } _state = state; @@ -2539,7 +2672,11 @@ Ice::ConnectionI::initiateShutdown() // // Notify the the transceiver of the graceful connection closure. // +#ifdef ICE_CPP11_MAPPING + SocketOperation op = _transceiver->closing(true, _exception); +#else SocketOperation op = _transceiver->closing(true, *_exception.get()); +#endif if(op) { scheduleTimeout(op); @@ -2575,7 +2712,7 @@ Ice::ConnectionI::heartbeat() catch(const LocalException& ex) { setState(StateClosed, ex); - assert(_exception.get()); + assert(ICE_EXCEPTION_GET(_exception)); } } } @@ -2885,7 +3022,11 @@ Ice::ConnectionI::sendNextMessage(vector<OutgoingMessage>& callbacks) if(_state == StateClosing && _shutdownInitiated) { setState(StateClosingPending); +#ifdef ICE_CPP11_MAPPING + SocketOperation op = _transceiver->closing(true, _exception); +#else SocketOperation op = _transceiver->closing(true, *_exception.get()); +#endif if(op) { return op; @@ -3266,7 +3407,11 @@ Ice::ConnectionI::parseMessage(BasicStream& stream, Int& invokeNum, Int& request // // Notify the the transceiver of the graceful connection closure. // +#ifdef ICE_CPP11_MAPPING + SocketOperation op = _transceiver->closing(false, _exception); +#else SocketOperation op = _transceiver->closing(false, *_exception.get()); +#endif if(op) { return op; diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index 4466097ad64..2109b52f6b3 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -366,7 +366,11 @@ private: std::map<Int, IceInternal::OutgoingAsyncBasePtr> _asyncRequests; std::map<Int, IceInternal::OutgoingAsyncBasePtr>::iterator _asyncRequestsHint; +#ifdef ICE_CPP11_MAPPING + std::exception_ptr _exception; +#else IceUtil::UniquePtr<LocalException> _exception; +#endif const size_t _messageSizeMax; IceInternal::BatchRequestQueuePtr _batchRequestQueue; diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp index 9516548a5be..5581237a7cf 100644 --- a/cpp/src/Ice/LocatorInfo.cpp +++ b/cpp/src/Ice/LocatorInfo.cpp @@ -418,7 +418,7 @@ IceInternal::LocatorInfo::Request::addCallback(const ReferencePtr& ref, RequestCallbackPtr callback = new RequestCallback(ref, ttl, cb); { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - if(!_response && !_exception.get()) + if(!_response && !ICE_EXCEPTION_GET(_exception)) { _callbacks.push_back(callback); if(wellKnownRef) // This request is to resolve the endpoints of a cached well-known object reference @@ -441,8 +441,19 @@ IceInternal::LocatorInfo::Request::addCallback(const ReferencePtr& ref, } else { - assert(_exception.get()); + assert(ICE_EXCEPTION_GET(_exception)); +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(_exception); + } + catch(const Ice::LocalException& ex) + { + callback->exception(_locatorInfo, ex); + } +#else callback->exception(_locatorInfo, *_exception.get()); +#endif } } @@ -453,7 +464,7 @@ IceInternal::LocatorInfo::Request::getEndpoints(const ReferencePtr& ref, bool& cached) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - if(!_response && !_exception.get()) + if(!_response && !ICE_EXCEPTION_GET(_exception)) { if(wellKnownRef) // This request is to resolve the endpoints of a cached well-known object reference { @@ -467,15 +478,26 @@ IceInternal::LocatorInfo::Request::getEndpoints(const ReferencePtr& ref, sync.acquire(); } - while(!_response && !_exception.get()) + while(!_response && !ICE_EXCEPTION_GET(_exception)) { _monitor.wait(); } } - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(_exception); + } + catch(const Ice::LocalException& ex) + { + _locatorInfo->getEndpointsException(ref, ex); // This throws. + } +#else _locatorInfo->getEndpointsException(ref, *_exception.get()); // This throws. +#endif } assert(_response); @@ -533,7 +555,11 @@ IceInternal::LocatorInfo::Request::exception(const Ice::Exception& ex) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); _locatorInfo->finishRequest(_ref, _wellKnownRefs, 0, dynamic_cast<const Ice::UserException*>(&ex)); +#ifdef ICE_CPP11_MAPPING + _exception = ex.ice_clone(); +#else _exception.reset(ex.ice_clone()); +#endif _monitor.notifyAll(); } for(vector<RequestCallbackPtr>::const_iterator p = _callbacks.begin(); p != _callbacks.end(); ++p) diff --git a/cpp/src/Ice/LocatorInfo.h b/cpp/src/Ice/LocatorInfo.h index c719eea134d..2c50be287d9 100644 --- a/cpp/src/Ice/LocatorInfo.h +++ b/cpp/src/Ice/LocatorInfo.h @@ -132,7 +132,11 @@ public: bool _sent; bool _response; Ice::ObjectPrxPtr _proxy; +#ifdef ICE_CPP11_MAPPING + std::exception_ptr _exception; +#else IceUtil::UniquePtr<Ice::Exception> _exception; +#endif }; typedef IceUtil::Handle<Request> RequestPtr; diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index bc0e28e3eff..d3291ff1ddf 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -86,7 +86,11 @@ ProxyOutgoingBase::completed(const Ice::Exception& ex) _childObserver.detach(); _state = StateFailed; +#ifdef ICE_CPP11_MAPPING + _exception = ex.ice_clone(); +#else _exception.reset(ex.ice_clone()); +#endif _monitor.notify(); } @@ -122,7 +126,11 @@ ProxyOutgoingBase::invokeImpl() } _state = StateInProgress; +#ifdef ICE_CPP11_MAPPING + _exception = nullptr; +#else _exception.reset(0); +#endif _sent = false; _handler = _proxy->__getRequestHandler(); @@ -206,9 +214,9 @@ ProxyOutgoingBase::invokeImpl() } } - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { - _exception->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); } else if(_state == StateRetry) { @@ -501,7 +509,11 @@ Outgoing::completed(BasicStream& is) ex->id = ident; ex->facet = facet; ex->operation = operation; +#ifdef ICE_CPP11_MAPPING + _exception = ex->ice_clone(); +#else _exception.reset(ex); +#endif _state = StateLocalException; // The state must be set last, in case there is an exception. break; @@ -549,15 +561,29 @@ Outgoing::completed(BasicStream& is) } ex->unknown = unknown; +#ifdef ICE_CPP11_MAPPING + _exception = ex->ice_clone(); +#else _exception.reset(ex); - +#endif _state = StateLocalException; // The state must be set last, in case there is an exception. break; } default: { +#ifdef ICE_CPP11_MAPPING + try + { + throw UnknownReplyStatusException(__FILE__, __LINE__); + } + catch(...) + { + _exception = current_exception(); + } +#else _exception.reset(new UnknownReplyStatusException(__FILE__, __LINE__)); +#endif _state = StateLocalException; break; } @@ -635,19 +661,19 @@ ConnectionFlushBatch::invoke() else if(!_connection->sendRequest(this, false, false, batchRequestNum)) { Monitor<Mutex>::Lock sync(_monitor); - while(!_exception.get() && !_sent) + while(!ICE_EXCEPTION_GET(_exception) && !_sent) { _monitor.wait(); } - if(_exception.get()) + if(ICE_EXCEPTION_GET(_exception)) { - _exception->ice_throw(); + ICE_RETHROW_EXCEPTION(_exception); } } } catch(const RetryException& ex) { - ex.get()->ice_throw(); + ICE_RETHROW_EXCEPTION(ex.get()); } } @@ -673,7 +699,11 @@ ConnectionFlushBatch::completed(const Ice::Exception& ex) Monitor<Mutex>::Lock sync(_monitor); _childObserver.failed(ex.ice_name()); _childObserver.detach(); +#ifdef ICE_CPP11_MAPPING + _exception = ex.ice_clone(); +#else _exception.reset(ex.ice_clone()); +#endif _monitor.notify(); } diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index d3af4f3d780..74bdd2c9bd0 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -863,10 +863,24 @@ ConnectionFlushBatchAsync::invoke() } catch(const RetryException& ex) { +#ifdef ICE_CPP11_MAPPING + try + { + rethrow_exception(ex.get()); + } + catch(const Ice::LocalException& ee) + { + if(completed(ee)) + { + invokeCompletedAsync(); + } + } +#else if(completed(*ex.get())) { invokeCompletedAsync(); } +#endif } catch(const Exception& ex) { diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index e2b36e92ffa..bc635c8e0a9 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -1773,6 +1773,25 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all virtual void setException(const Ice::LocalException& ex) { +#ifdef ICE_CPP11_MAPPING + if(!_exception) + { + _exception = ex.ice_clone(); + } + + try + { + rethrow_exception(_exception); + } + catch(const Ice::LocalException& ee) + { + if(++_i == _endpoints.size()) + { + _callback->setException(ee); + return; + } + } +#else if(!_exception.get()) { _exception.reset(ex.ice_clone()); @@ -1783,7 +1802,7 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all _callback->setException(*_exception.get()); return; } - +#endif const bool more = _i != _endpoints.size() - 1; vector<EndpointIPtr> endpoint; endpoint.push_back(_endpoints[_i]); @@ -1807,7 +1826,11 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all const vector<EndpointIPtr> _endpoints; const GetConnectionCallbackPtr _callback; size_t _i; +#ifdef ICE_CPP11_MAPPING + std::exception_ptr _exception; +#else IceUtil::UniquePtr<Ice::LocalException> _exception; +#endif }; // diff --git a/cpp/src/Ice/RequestHandler.cpp b/cpp/src/Ice/RequestHandler.cpp index 62acf7e4ef3..74bcb8daf40 100644 --- a/cpp/src/Ice/RequestHandler.cpp +++ b/cpp/src/Ice/RequestHandler.cpp @@ -13,10 +13,25 @@ using namespace std; using namespace IceInternal; -#ifndef ICE_CPP11_MAPPING +#ifdef ICE_CPP11_MAPPING +RetryException::RetryException(std::exception_ptr ex) : _ex(ex) +{ +} + +RetryException::RetryException(const RetryException& ex) : _ex(ex.get()) +{ +} + +exception_ptr +RetryException::get() const +{ + assert(_ex); + return _ex; +} + +#else IceUtil::Shared* IceInternal::upCast(RequestHandler* p) { return p; } IceUtil::Shared* IceInternal::upCast(CancellationHandler* p) { return p; } -#endif RetryException::RetryException(const Ice::LocalException& ex) { @@ -34,9 +49,10 @@ RetryException::get() const assert(_ex.get()); return _ex.get(); } +#endif RequestHandler::RequestHandler(const ReferencePtr& reference) : _reference(reference), _response(reference->getMode() == Reference::ModeTwoway) { -} +}
\ No newline at end of file diff --git a/cpp/src/Ice/RequestHandler.h b/cpp/src/Ice/RequestHandler.h index cfe7db10845..d222c8787c8 100644 --- a/cpp/src/Ice/RequestHandler.h +++ b/cpp/src/Ice/RequestHandler.h @@ -38,6 +38,21 @@ class ProxyOutgoingBase; // An exception wrapper, which is used to notify that the request // handler should be cleared and the invocation retried. // +#ifdef ICE_CPP11_MAPPING +class RetryException +{ +public: + + RetryException(std::exception_ptr); + RetryException(const RetryException&); + + std::exception_ptr get() const; + +private: + + std::exception_ptr _ex; +}; +#else class RetryException { public: @@ -51,6 +66,8 @@ private: IceUtil::UniquePtr<Ice::LocalException> _ex; }; +#endif + class CancellationHandler #ifndef ICE_CPP11_MAPPING diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp index 6e744ff4919..842c1a6feb1 100644 --- a/cpp/src/Ice/TcpTransceiver.cpp +++ b/cpp/src/Ice/TcpTransceiver.cpp @@ -31,7 +31,11 @@ IceInternal::TcpTransceiver::initialize(Buffer& readBuffer, Buffer& writeBuffer) } SocketOperation +#ifdef ICE_CPP11_MAPPING +IceInternal::TcpTransceiver::closing(bool initiator, exception_ptr) +#else IceInternal::TcpTransceiver::closing(bool initiator, const Ice::LocalException&) +#endif { // If we are initiating the connection closure, wait for the peer // to close the TCP/IP connection. Otherwise, close immediately. diff --git a/cpp/src/Ice/TcpTransceiver.h b/cpp/src/Ice/TcpTransceiver.h index b192ab1bd44..f5ac2510778 100644 --- a/cpp/src/Ice/TcpTransceiver.h +++ b/cpp/src/Ice/TcpTransceiver.h @@ -29,7 +29,11 @@ public: virtual NativeInfoPtr getNativeInfo(); virtual SocketOperation initialize(Buffer&, Buffer&); +#ifdef ICE_CPP11_MAPPING + virtual SocketOperation closing(bool, std::exception_ptr); +#else virtual SocketOperation closing(bool, const Ice::LocalException&); +#endif virtual void close(); virtual SocketOperation write(Buffer&); virtual SocketOperation read(Buffer&); diff --git a/cpp/src/Ice/Transceiver.h b/cpp/src/Ice/Transceiver.h index d277e9bb746..b9ca6e14f40 100644 --- a/cpp/src/Ice/Transceiver.h +++ b/cpp/src/Ice/Transceiver.h @@ -28,7 +28,11 @@ public: virtual NativeInfoPtr getNativeInfo() = 0; virtual SocketOperation initialize(Buffer&, Buffer&) = 0; +#ifdef ICE_CPP11_MAPPING + virtual SocketOperation closing(bool, std::exception_ptr) = 0; +#else virtual SocketOperation closing(bool, const Ice::LocalException&) = 0; +#endif virtual void close() = 0; virtual EndpointIPtr bind(); virtual SocketOperation write(Buffer&) = 0; diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index 072fbe52da1..bf79f8b453d 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -106,7 +106,11 @@ IceInternal::UdpTransceiver::initialize(Buffer& /*readBuffer*/, Buffer& /*writeB } SocketOperation +#ifdef ICE_CPP11_MAPPING +IceInternal::UdpTransceiver::closing(bool, exception_ptr) +#else IceInternal::UdpTransceiver::closing(bool, const Ice::LocalException&) +#endif { // Nothing to do. return SocketOperationNone; diff --git a/cpp/src/Ice/UdpTransceiver.h b/cpp/src/Ice/UdpTransceiver.h index 7c1edfc3c6f..20d3eafb82d 100644 --- a/cpp/src/Ice/UdpTransceiver.h +++ b/cpp/src/Ice/UdpTransceiver.h @@ -45,7 +45,11 @@ public: #endif virtual SocketOperation initialize(Buffer&, Buffer&); +#ifdef ICE_CPP11_MAPPING + virtual SocketOperation closing(bool, std::exception_ptr); +#else virtual SocketOperation closing(bool, const Ice::LocalException&); +#endif virtual void close(); virtual EndpointIPtr bind(); virtual SocketOperation write(Buffer&); diff --git a/cpp/src/Ice/WSTransceiver.cpp b/cpp/src/Ice/WSTransceiver.cpp index bd9254a22bb..e172651c026 100644 --- a/cpp/src/Ice/WSTransceiver.cpp +++ b/cpp/src/Ice/WSTransceiver.cpp @@ -416,7 +416,11 @@ IceInternal::WSTransceiver::initialize(Buffer& readBuffer, Buffer& writeBuffer) } SocketOperation +#ifdef ICE_CPP11_MAPPING +IceInternal::WSTransceiver::closing(bool initiator, exception_ptr reason) +#else IceInternal::WSTransceiver::closing(bool initiator, const Ice::LocalException& reason) +#endif { if(_instance->traceLevel() >= 1) { @@ -446,6 +450,38 @@ IceInternal::WSTransceiver::closing(bool initiator, const Ice::LocalException& r } _closingInitiator = initiator; +#ifdef ICE_CPP11_MAPPING + if(reason) + { + try + { + rethrow_exception(reason); + } + catch(const Ice::CloseConnectionException&) + { + _closingReason = CLOSURE_NORMAL; + } + catch(const Ice::ObjectAdapterDeactivatedException&) + { + _closingReason = CLOSURE_SHUTDOWN; + } + catch(Ice::CommunicatorDestroyedException&) + { + _closingReason = CLOSURE_SHUTDOWN; + } + catch(const Ice::MemoryLimitException&) + { + _closingReason = CLOSURE_TOO_BIG; + } + catch(const Ice::ProtocolException&) + { + _closingReason = CLOSURE_PROTOCOL_ERROR; + } + catch(...) + { + } + } +#else if(dynamic_cast<const Ice::CloseConnectionException*>(&reason)) { _closingReason = CLOSURE_NORMAL; @@ -463,6 +499,7 @@ IceInternal::WSTransceiver::closing(bool initiator, const Ice::LocalException& r { _closingReason = CLOSURE_TOO_BIG; } +#endif if(_state == StateOpened) { diff --git a/cpp/src/Ice/WSTransceiver.h b/cpp/src/Ice/WSTransceiver.h index b7771ecece9..c35d739aead 100644 --- a/cpp/src/Ice/WSTransceiver.h +++ b/cpp/src/Ice/WSTransceiver.h @@ -47,7 +47,11 @@ public: #endif virtual SocketOperation initialize(Buffer&, Buffer&); +#ifdef ICE_CPP11_MAPPING + virtual SocketOperation closing(bool, std::exception_ptr); +#else virtual SocketOperation closing(bool, const Ice::LocalException&); +#endif virtual void close(); virtual SocketOperation write(Buffer&); virtual SocketOperation read(Buffer&); diff --git a/cpp/src/IceBT/TransceiverI.cpp b/cpp/src/IceBT/TransceiverI.cpp index ef0863ddcf1..fa89d2b900a 100644 --- a/cpp/src/IceBT/TransceiverI.cpp +++ b/cpp/src/IceBT/TransceiverI.cpp @@ -35,7 +35,11 @@ IceBT::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::Bu } IceInternal::SocketOperation +#ifdef ICE_CPP11_MAPPING +IceBT::TransceiverI::closing(bool initiator, exception_ptr) +#else IceBT::TransceiverI::closing(bool initiator, const Ice::LocalException&) +#endif { // // If we are initiating the connection closure, wait for the peer diff --git a/cpp/src/IceBT/TransceiverI.h b/cpp/src/IceBT/TransceiverI.h index 0f8df49e9cf..df2fcbcefd3 100644 --- a/cpp/src/IceBT/TransceiverI.h +++ b/cpp/src/IceBT/TransceiverI.h @@ -28,7 +28,11 @@ public: virtual IceInternal::NativeInfoPtr getNativeInfo(); virtual IceInternal::SocketOperation initialize(IceInternal::Buffer&, IceInternal::Buffer&); +#ifdef ICE_CPP11_MAPPING + virtual IceInternal::SocketOperation closing(bool, std::exception_ptr); +#else virtual IceInternal::SocketOperation closing(bool, const Ice::LocalException&); +#endif virtual void close(); virtual IceInternal::SocketOperation write(IceInternal::Buffer&); virtual IceInternal::SocketOperation read(IceInternal::Buffer&); diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp index 22856132b76..2968b879620 100644 --- a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +++ b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp @@ -312,7 +312,11 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B } IceInternal::SocketOperation +#ifdef ICE_CPP11_MAPPING +IceSSL::TransceiverI::closing(bool initiator, exception_ptr) +#else IceSSL::TransceiverI::closing(bool initiator, const Ice::LocalException&) +#endif { // If we are initiating the connection closure, wait for the peer // to close the TCP/IP connection. Otherwise, close immediately. diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.h b/cpp/src/IceSSL/OpenSSLTransceiverI.h index eb81b12ec12..f5c73c75d50 100644 --- a/cpp/src/IceSSL/OpenSSLTransceiverI.h +++ b/cpp/src/IceSSL/OpenSSLTransceiverI.h @@ -39,7 +39,11 @@ public: virtual IceInternal::NativeInfoPtr getNativeInfo(); virtual IceInternal::SocketOperation initialize(IceInternal::Buffer&, IceInternal::Buffer&); +#ifdef ICE_CPP11_MAPPING + virtual IceInternal::SocketOperation closing(bool, std::exception_ptr); +#else virtual IceInternal::SocketOperation closing(bool, const Ice::LocalException&); +#endif virtual void close(); virtual IceInternal::SocketOperation write(IceInternal::Buffer&); virtual IceInternal::SocketOperation read(IceInternal::Buffer&); diff --git a/cpp/src/IceSSL/SChannelTransceiverI.cpp b/cpp/src/IceSSL/SChannelTransceiverI.cpp index 792a283db8b..8ada0b88a3a 100644 --- a/cpp/src/IceSSL/SChannelTransceiverI.cpp +++ b/cpp/src/IceSSL/SChannelTransceiverI.cpp @@ -752,7 +752,11 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B } IceInternal::SocketOperation +#ifdef ICE_CPP11_MAPPING +IceSSL::TransceiverI::closing(bool initiator, exception_ptr) +#else IceSSL::TransceiverI::closing(bool initiator, const Ice::LocalException&) +#endif { // If we are initiating the connection closure, wait for the peer // to close the TCP/IP connection. Otherwise, close immediately. diff --git a/cpp/src/IceSSL/SChannelTransceiverI.h b/cpp/src/IceSSL/SChannelTransceiverI.h index a4eb31ab46f..51d3615eb78 100644 --- a/cpp/src/IceSSL/SChannelTransceiverI.h +++ b/cpp/src/IceSSL/SChannelTransceiverI.h @@ -50,7 +50,11 @@ public: virtual IceInternal::NativeInfoPtr getNativeInfo(); virtual IceInternal::SocketOperation initialize(IceInternal::Buffer&, IceInternal::Buffer&); +#ifdef ICE_CPP11_MAPPING + virtual IceInternal::SocketOperation closing(bool, std::exception_ptr); +#else virtual IceInternal::SocketOperation closing(bool, const Ice::LocalException&); +#endif virtual void close(); virtual IceInternal::SocketOperation write(IceInternal::Buffer&); virtual IceInternal::SocketOperation read(IceInternal::Buffer&); diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp index 99f4571224e..2969dcb4370 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp @@ -290,7 +290,11 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B } IceInternal::SocketOperation +#ifdef ICE_CPP11_MAPPING +IceSSL::TransceiverI::closing(bool initiator, exception_ptr) +#else IceSSL::TransceiverI::closing(bool initiator, const Ice::LocalException&) +#endif { // If we are initiating the connection closure, wait for the peer // to close the TCP/IP connection. Otherwise, close immediately. diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.h b/cpp/src/IceSSL/SecureTransportTransceiverI.h index f50a17de13d..dae6b1806fc 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.h +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.h @@ -38,7 +38,11 @@ public: virtual IceInternal::NativeInfoPtr getNativeInfo(); virtual IceInternal::SocketOperation initialize(IceInternal::Buffer&, IceInternal::Buffer&); +#ifdef ICE_CPP11_MAPPING + virtual IceInternal::SocketOperation closing(bool, std::exception_ptr); +#else virtual IceInternal::SocketOperation closing(bool, const Ice::LocalException&); +#endif virtual void close(); virtual IceInternal::SocketOperation write(IceInternal::Buffer&); virtual IceInternal::SocketOperation read(IceInternal::Buffer&); diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index 1cdacff1e62..869e160b9de 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -451,11 +451,28 @@ IceUtil::Exception::what() const throw() return ""; } +#ifdef ICE_CPP11_MAPPING +exception_ptr +IceUtil::Exception::ice_clone() const +{ + try + { + ice_throw(); + } + catch(...) + { + return current_exception(); + } + assert(false); + return nullptr; // Make compilers happy +} +#else IceUtil::Exception* IceUtil::Exception::ice_clone() const { return new Exception(*this); } +#endif void IceUtil::Exception::ice_throw() const @@ -509,11 +526,13 @@ IceUtil::NullHandleException::ice_name() const return _name; } +#ifndef ICE_CPP11_MAPPING IceUtil::NullHandleException* IceUtil::NullHandleException::ice_clone() const { return new NullHandleException(*this); } +#endif void IceUtil::NullHandleException::ice_throw() const @@ -551,11 +570,13 @@ IceUtil::IllegalArgumentException::ice_print(ostream& out) const out << ": " << _reason; } +#ifndef ICE_CPP11_MAPPING IceUtil::IllegalArgumentException* IceUtil::IllegalArgumentException::ice_clone() const { return new IllegalArgumentException(*this); } +#endif void IceUtil::IllegalArgumentException::ice_throw() const @@ -602,11 +623,13 @@ IceUtil::IllegalConversionException::ice_print(ostream& out) const } +#ifndef ICE_CPP11_MAPPING IceUtil::IllegalConversionException* IceUtil::IllegalConversionException::ice_clone() const { return new IllegalConversionException(*this); } +#endif void IceUtil::IllegalConversionException::ice_throw() const @@ -646,11 +669,13 @@ IceUtil::SyscallException::ice_print(ostream& os) const } } +#ifndef ICE_CPP11_MAPPING IceUtil::SyscallException* IceUtil::SyscallException::ice_clone() const { return new SyscallException(*this); } +#endif void IceUtil::SyscallException::ice_throw() const @@ -695,11 +720,13 @@ IceUtil::FileLockException::ice_print(ostream& os) const } } +#ifndef ICE_CPP11_MAPPING IceUtil::FileLockException* IceUtil::FileLockException::ice_clone() const { return new FileLockException(*this); } +#endif void IceUtil::FileLockException::ice_throw() const @@ -734,11 +761,13 @@ IceUtil::OptionalNotSetException::ice_name() const return _name; } +#ifndef ICE_CPP11_MAPPING IceUtil::OptionalNotSetException* IceUtil::OptionalNotSetException::ice_clone() const { return new OptionalNotSetException(*this); } +#endif void IceUtil::OptionalNotSetException::ice_throw() const @@ -772,11 +801,13 @@ IceUtil::IconvInitializationException::ice_print(ostream& out) const out << ": " << _reason; } +#ifndef ICE_CPP11_MAPPING IceUtil::IconvInitializationException* IceUtil::IconvInitializationException::ice_clone() const { return new IconvInitializationException(*this); } +#endif void IceUtil::IconvInitializationException::ice_throw() const diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 2a0bef6063c..4ee33bada58 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -5654,12 +5654,6 @@ Slice::Gen::Cpp11TypesVisitor::visitExceptionStart(const ExceptionPtr& p) H << nl << "virtual void ice_print(::std::ostream&) const;"; } - H << nl << "virtual " << name << "* ice_clone() const;"; - C << sp << nl << scoped.substr(2) << "*" << nl << scoped.substr(2) << "::ice_clone() const"; - C << sb; - C << nl << "return new " << name << "(*this);"; - C << eb; - H << nl << "virtual void ice_throw() const;"; C << sp << nl << "void" << nl << scoped.substr(2) << "::ice_throw() const"; C << sb; |