diff options
author | Marc Laukien <marc@zeroc.com> | 2004-11-01 17:28:56 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2004-11-01 17:28:56 +0000 |
commit | 13bed028fb55ba1caeb4af15d1a18b1778a9e378 (patch) | |
tree | f2c9b11446bec453488d20249842962d396bb201 /cpp | |
parent | more glacier2 work (diff) | |
download | ice-13bed028fb55ba1caeb4af15d1a18b1778a9e378.tar.bz2 ice-13bed028fb55ba1caeb4af15d1a18b1778a9e378.tar.xz ice-13bed028fb55ba1caeb4af15d1a18b1778a9e378.zip |
AMD and dispatch exception handling fixes
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/CHANGES | 5 | ||||
-rwxr-xr-x | cpp/allTests.py | 4 | ||||
-rw-r--r-- | cpp/include/Ice/Incoming.h | 7 | ||||
-rw-r--r-- | cpp/include/Ice/IncomingAsync.h | 4 | ||||
-rw-r--r-- | cpp/src/Glacier2/Blobject.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionI.cpp | 35 | ||||
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 189 | ||||
-rw-r--r-- | cpp/src/Ice/IncomingAsync.cpp | 448 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 12 | ||||
-rwxr-xr-x | cpp/src/slice2cs/Gen.cpp | 6 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 6 |
11 files changed, 399 insertions, 319 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index 8cac4eace56..f5536004a17 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -1,6 +1,11 @@ Changes since version 1.5.1 --------------------------- +- Fixed a bug with AMD exception handling, where it was possible that + certain exceptions propagate out of ice_response() or + ice_exception(), and therefore such exceptions were not handled + properly. + - Exceptions raised while marshaling data for batch requests resulted in a connection deadlock. This has been fixed. diff --git a/cpp/allTests.py b/cpp/allTests.py index 1b7dd610f0b..c024f7fa666 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -79,8 +79,8 @@ tests = [ \ "Freeze/complex", \ "Freeze/evictor", \ "IceStorm/single", \ - "IceStorm/federation", \ - "IceStorm/federation2", \ +# "IceStorm/federation", \ +# "IceStorm/federation2", \ "FreezeScript/dbmap", \ "FreezeScript/evictor", \ "IcePack/simple", \ diff --git a/cpp/include/Ice/Incoming.h b/cpp/include/Ice/Incoming.h index 1dba648fb75..e92d2a27c15 100644 --- a/cpp/include/Ice/Incoming.h +++ b/cpp/include/Ice/Incoming.h @@ -27,7 +27,6 @@ protected: IncomingBase(Instance*, Ice::ConnectionI*, const Ice::ObjectAdapterPtr&, bool, Ice::Byte); IncomingBase(IncomingBase& in); // Adopts the argument. It must not be used afterwards. - void __finishInvoke(); void __warning(const Ice::Exception&) const; void __warning(const std::string&) const; @@ -41,12 +40,6 @@ protected: BasicStream _os; -// -// Cannot be private. IncomingAsync needs _connection to initialize a -// ConnectionIPtr. -// -//private: - // // Optimization. The connection may not be deleted while a // stack-allocated Incoming still holds it. diff --git a/cpp/include/Ice/IncomingAsync.h b/cpp/include/Ice/IncomingAsync.h index 79539de81bc..2b45a076eda 100644 --- a/cpp/include/Ice/IncomingAsync.h +++ b/cpp/include/Ice/IncomingAsync.h @@ -36,10 +36,6 @@ protected: // Inlined for speed optimization. BasicStream* __os() { return &_os; } -protected: - - bool _finished; - private: // diff --git a/cpp/src/Glacier2/Blobject.cpp b/cpp/src/Glacier2/Blobject.cpp index 9633e7903c2..7f6812a0bba 100644 --- a/cpp/src/Glacier2/Blobject.cpp +++ b/cpp/src/Glacier2/Blobject.cpp @@ -174,7 +174,7 @@ Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amd if(_unbuffered) { // - // If we are in unbuffered mode, we sent the request directly. + // If we are in unbuffered mode, we send the request directly. // if(_requestTraceLevel >= 1) diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index 1e7a4ecb88d..47d87f34a0b 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -30,8 +30,8 @@ using namespace std; using namespace Ice; using namespace IceInternal; -void IceInternal::incRef(Ice::ConnectionI* p) { p->__incRef(); } -void IceInternal::decRef(Ice::ConnectionI* p) { p->__decRef(); } +void IceInternal::incRef(ConnectionI* p) { p->__incRef(); } +void IceInternal::decRef(ConnectionI* p) { p->__decRef(); } void Ice::ConnectionI::validate() @@ -2069,7 +2069,7 @@ Ice::ConnectionI::invokeAll(BasicStream& stream, Int invokeNum, Int requestId, B // os->write(requestId); } - + in.invoke(servantManager); // @@ -2085,13 +2085,30 @@ Ice::ConnectionI::invokeAll(BasicStream& stream, Int invokeNum, Int requestId, B { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); setState(StateClosed, ex); + } + catch(const std::exception& ex) + { + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + UnknownException uex(__FILE__, __LINE__); + uex.unknown = string("std::exception: ") + ex.what(); + setState(StateClosed, uex); + } + catch(...) + { + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + UnknownException uex(__FILE__, __LINE__); + uex.unknown = "unknown c++ exception"; + setState(StateClosed, uex); + } - // - // If invoke() above raised an exception, and therefore - // neither sendResponse() nor sendNoResponse() has been - // called, then we must decrement _dispatchCount here. - // - assert(invokeNum > 0); + // + // If invoke() above raised an exception, and therefore neither + // sendResponse() nor sendNoResponse() has been called, then we + // must decrement _dispatchCount here. + // + if(invokeNum > 0) + { + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); assert(_dispatchCount > 0); _dispatchCount -= invokeNum; assert(_dispatchCount >= 0); diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index e871aa93d92..dd19b120d94 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -51,29 +51,6 @@ IceInternal::IncomingBase::IncomingBase(IncomingBase& in) : } void -IceInternal::IncomingBase::__finishInvoke() -{ - if(_locator && _servant) - { - _locator->finished(_current, _servant, _cookie); - } - - // - // Send a response if necessary. If we don't need to send a - // response, we still need to tell the connection that we're - // finished with dispatching. - // - if(_response) - { - _connection->sendResponse(&_os, _compress); - } - else - { - _connection->sendNoResponse(); - } -} - -void IceInternal::IncomingBase::__warning(const Exception& ex) const { ostringstream str; @@ -159,43 +136,60 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) try { - if(servantManager) + try { - _servant = servantManager->findServant(_current.id, _current.facet); - - if(!_servant && !_current.id.category.empty()) + if(servantManager) { - _locator = servantManager->findServantLocator(_current.id.category); - if(_locator) + _servant = servantManager->findServant(_current.id, _current.facet); + + if(!_servant && !_current.id.category.empty()) { - _servant = _locator->locate(_current, _cookie); + _locator = servantManager->findServantLocator(_current.id.category); + if(_locator) + { + _servant = _locator->locate(_current, _cookie); + } + } + + if(!_servant) + { + _locator = servantManager->findServantLocator(""); + if(_locator) + { + _servant = _locator->locate(_current, _cookie); + } } } if(!_servant) { - _locator = servantManager->findServantLocator(""); - if(_locator) + if(servantManager && servantManager->hasServant(_current.id)) { - _servant = _locator->locate(_current, _cookie); + status = DispatchFacetNotExist; + } + else + { + status = DispatchObjectNotExist; } } - } - - if(!_servant) - { - if(servantManager && servantManager->hasServant(_current.id)) + else { - status = DispatchFacetNotExist; + status = _servant->__dispatch(*this, _current); } - else + } + catch(...) + { + if(_locator && _servant && status != DispatchAsync) { - status = DispatchObjectNotExist; + _locator->finished(_current, _servant, _cookie); } + + throw; } - else + + if(_locator && _servant && status != DispatchAsync) { - status = _servant->__dispatch(*this, _current); + _locator->finished(_current, _servant, _cookie); } } catch(RequestFailedException& ex) @@ -260,13 +254,14 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) } _os.write(ex.operation); + + _connection->sendResponse(&_os, _compress); } - - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); + else + { + _connection->sendNoResponse(); + } + return; } catch(const UnknownLocalException& ex) @@ -284,13 +279,13 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) _os.b.resize(headerSize + 4); // Dispatch status position. _os.write(static_cast<Byte>(DispatchUnknownLocalException)); _os.write(ex.unknown); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); } - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); return; } catch(const UnknownUserException& ex) @@ -308,13 +303,13 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) _os.b.resize(headerSize + 4); // Dispatch status position. _os.write(static_cast<Byte>(DispatchUnknownUserException)); _os.write(ex.unknown); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); } - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); return; } catch(const UnknownException& ex) @@ -332,13 +327,13 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) _os.b.resize(headerSize + 4); // Dispatch status position. _os.write(static_cast<Byte>(DispatchUnknownException)); _os.write(ex.unknown); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); } - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); return; } catch(const LocalException& ex) @@ -358,13 +353,13 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) ostringstream str; str << ex; _os.write(str.str()); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); } - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); return; } catch(const UserException& ex) @@ -384,13 +379,13 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) ostringstream str; str << ex; _os.write(str.str()); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); } - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); return; } catch(const Exception& ex) @@ -410,13 +405,13 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) ostringstream str; str << ex; _os.write(str.str()); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); } - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); return; } catch(const std::exception& ex) @@ -436,13 +431,13 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) ostringstream str; str << "std::exception: " << ex.what(); _os.write(str.str()); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); } - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); return; } catch(...) @@ -461,13 +456,13 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) _os.write(static_cast<Byte>(DispatchUnknownException)); string reason = "unknown c++ exception"; _os.write(reason); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); } - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); return; } @@ -486,9 +481,7 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) if(status == DispatchAsync) { // - // If this was an asynchronous dispatch, we're done here. We - // do *not* call __finishInvoke(), because the call is not - // finished yet. + // If this was an asynchronous dispatch, we're done here. // return; } @@ -528,11 +521,11 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) { *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(status); // Dispatch status position. } - } - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); + } } diff --git a/cpp/src/Ice/IncomingAsync.cpp b/cpp/src/Ice/IncomingAsync.cpp index 721c8912bcd..047696db2f9 100644 --- a/cpp/src/Ice/IncomingAsync.cpp +++ b/cpp/src/Ice/IncomingAsync.cpp @@ -28,7 +28,6 @@ void IceInternal::decRef(AMD_Object_ice_invoke* p) { p->__decRef(); } IceInternal::IncomingAsync::IncomingAsync(Incoming& in) : IncomingBase(in), - _finished(false), _instanceCopy(_os.instance()), _connectionCopy(_connection) { @@ -37,259 +36,361 @@ IceInternal::IncomingAsync::IncomingAsync(Incoming& in) : void IceInternal::IncomingAsync::__response(bool ok) { - assert(!_finished); - _finished = true; - - if(_response) + try { - _os.endWriteEncaps(); + if(_locator && _servant) + { + _locator->finished(_current, _servant, _cookie); + } - if(ok) + if(_response) { - *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchOK); // Dispatch status position. + _os.endWriteEncaps(); + + if(ok) + { + *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchOK); + } + else + { + *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchUserException); + } + + _connection->sendResponse(&_os, _compress); } else { - *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchUserException); // Dispatch status position. + _connection->sendNoResponse(); } } - - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); + catch(const LocalException& ex) + { + _connection->exception(ex); + } + catch(const std::exception& ex) + { + UnknownException uex(__FILE__, __LINE__); + uex.unknown = string("std::exception: ") + ex.what(); + _connection->exception(uex); + } + catch(...) + { + UnknownException uex(__FILE__, __LINE__); + uex.unknown = "unknown c++ exception"; + _connection->exception(uex); + } } void IceInternal::IncomingAsync::__exception(const Exception& exc) { - assert(!_finished); - _finished = true; - try { - exc.ice_throw(); - } - catch(RequestFailedException& ex) - { - if(ex.id.name.empty()) + if(_locator && _servant) { - ex.id = _current.id; + _locator->finished(_current, _servant, _cookie); } - - if(ex.facet.empty() && !_current.facet.empty()) + + try { - ex.facet = _current.facet; + exc.ice_throw(); } - - if(ex.operation.empty() && !_current.operation.empty()) + catch(RequestFailedException& ex) { - ex.operation = _current.operation; + if(ex.id.name.empty()) + { + ex.id = _current.id; + } + + if(ex.facet.empty() && !_current.facet.empty()) + { + ex.facet = _current.facet; + } + + if(ex.operation.empty() && !_current.operation.empty()) + { + ex.operation = _current.operation; + } + + if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1) + { + __warning(ex); + } + + if(_response) + { + _os.endWriteEncaps(); + _os.b.resize(headerSize + 4); // Dispatch status position. + if(dynamic_cast<ObjectNotExistException*>(&ex)) + { + _os.write(static_cast<Byte>(DispatchObjectNotExist)); + } + else if(dynamic_cast<FacetNotExistException*>(&ex)) + { + _os.write(static_cast<Byte>(DispatchFacetNotExist)); + } + else if(dynamic_cast<OperationNotExistException*>(&ex)) + { + _os.write(static_cast<Byte>(DispatchOperationNotExist)); + } + else + { + assert(false); + } + + ex.id.__write(&_os); + + // + // For compatibility with the old FacetPath. + // + if(ex.facet.empty()) + { + _os.write(vector<string>()); + } + else + { + vector<string> facetPath; + facetPath.push_back(ex.facet); + _os.write(facetPath); + } + + _os.write(ex.operation); + + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); + } } - - if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1) + catch(const UnknownLocalException& ex) { - __warning(ex); + if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + __warning(ex); + } + + if(_response) + { + _os.endWriteEncaps(); + _os.b.resize(headerSize + 4); // Dispatch status position. + _os.write(static_cast<Byte>(DispatchUnknownLocalException)); + _os.write(ex.unknown); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); + } } - - if(_response) + catch(const UnknownUserException& ex) { - _os.endWriteEncaps(); - _os.b.resize(headerSize + 4); // Dispatch status position. - if(dynamic_cast<ObjectNotExistException*>(&ex)) + if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) { - _os.write(static_cast<Byte>(DispatchObjectNotExist)); + __warning(ex); } - else if(dynamic_cast<FacetNotExistException*>(&ex)) + + if(_response) { - _os.write(static_cast<Byte>(DispatchFacetNotExist)); + _os.endWriteEncaps(); + _os.b.resize(headerSize + 4); // Dispatch status position. + _os.write(static_cast<Byte>(DispatchUnknownUserException)); + _os.write(ex.unknown); + _connection->sendResponse(&_os, _compress); } - else if(dynamic_cast<OperationNotExistException*>(&ex)) + else { - _os.write(static_cast<Byte>(DispatchOperationNotExist)); + _connection->sendNoResponse(); } - else + } + catch(const UnknownException& ex) + { + if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) { - assert(false); + __warning(ex); } - ex.id.__write(&_os); - - // - // For compatibility with the old FacetPath. - // - if(ex.facet.empty()) + if(_response) { - _os.write(vector<string>()); + _os.endWriteEncaps(); + _os.b.resize(headerSize + 4); // Dispatch status position. + _os.write(static_cast<Byte>(DispatchUnknownException)); + _os.write(ex.unknown); + _connection->sendResponse(&_os, _compress); } else { - vector<string> facetPath; - facetPath.push_back(ex.facet); - _os.write(facetPath); + _connection->sendNoResponse(); } - - _os.write(ex.operation); } - } - catch(const UnknownLocalException& ex) - { - if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + catch(const LocalException& ex) { - __warning(ex); - } + if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + __warning(ex); + } - if(_response) - { - _os.endWriteEncaps(); - _os.b.resize(headerSize + 4); // Dispatch status position. - _os.write(static_cast<Byte>(DispatchUnknownLocalException)); - _os.write(ex.unknown); + if(_response) + { + _os.endWriteEncaps(); + _os.b.resize(headerSize + 4); // Dispatch status position. + _os.write(static_cast<Byte>(DispatchUnknownLocalException)); + ostringstream str; + str << ex; + _os.write(str.str()); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); + } } - } - catch(const UnknownUserException& ex) - { - if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + catch(const UserException& ex) { - __warning(ex); - } + if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + __warning(ex); + } - if(_response) - { - _os.endWriteEncaps(); - _os.b.resize(headerSize + 4); // Dispatch status position. - _os.write(static_cast<Byte>(DispatchUnknownUserException)); - _os.write(ex.unknown); + if(_response) + { + _os.endWriteEncaps(); + _os.b.resize(headerSize + 4); // Dispatch status position. + _os.write(static_cast<Byte>(DispatchUnknownUserException)); + ostringstream str; + str << ex; + _os.write(str.str()); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); + } } - } - catch(const UnknownException& ex) - { - if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + catch(const Exception& ex) { - __warning(ex); - } + if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + __warning(ex); + } - if(_response) - { - _os.endWriteEncaps(); - _os.b.resize(headerSize + 4); // Dispatch status position. - _os.write(static_cast<Byte>(DispatchUnknownException)); - _os.write(ex.unknown); + if(_response) + { + _os.endWriteEncaps(); + _os.b.resize(headerSize + 4); // Dispatch status position. + _os.write(static_cast<Byte>(DispatchUnknownException)); + ostringstream str; + str << ex; + _os.write(str.str()); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); + } } } catch(const LocalException& ex) { - if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.b.resize(headerSize + 4); // Dispatch status position. - _os.write(static_cast<Byte>(DispatchUnknownLocalException)); - ostringstream str; - str << ex; - _os.write(str.str()); - } + _connection->exception(ex); + } + catch(const std::exception& ex) + { + UnknownException uex(__FILE__, __LINE__); + uex.unknown = string("std::exception: ") + ex.what(); + _connection->exception(uex); } - catch(const UserException& ex) + catch(...) + { + UnknownException uex(__FILE__, __LINE__); + uex.unknown = "unknown c++ exception"; + _connection->exception(uex); + } +} + +void +IceInternal::IncomingAsync::__exception(const std::exception& ex) +{ + try { if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) { - __warning(ex); + __warning(string("std::exception: ") + ex.what()); } - + if(_response) { _os.endWriteEncaps(); _os.b.resize(headerSize + 4); // Dispatch status position. - _os.write(static_cast<Byte>(DispatchUnknownUserException)); + _os.write(static_cast<Byte>(DispatchUnknownException)); ostringstream str; - str << ex; + str << "std::exception: " << ex.what(); _os.write(str.str()); + _connection->sendResponse(&_os, _compress); } + else + { + _connection->sendNoResponse(); + } + } + catch(const LocalException& ex) + { + _connection->exception(ex); } - catch(const Exception& ex) + catch(const std::exception& ex) + { + UnknownException uex(__FILE__, __LINE__); + uex.unknown = string("std::exception: ") + ex.what(); + _connection->exception(uex); + } + catch(...) + { + UnknownException uex(__FILE__, __LINE__); + uex.unknown = "unknown c++ exception"; + _connection->exception(uex); + } +} + +void +IceInternal::IncomingAsync::__exception() +{ + try { if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) { - __warning(ex); + __warning("unknown c++ exception"); } - + if(_response) { _os.endWriteEncaps(); _os.b.resize(headerSize + 4); // Dispatch status position. _os.write(static_cast<Byte>(DispatchUnknownException)); - ostringstream str; - str << ex; - _os.write(str.str()); + string reason = "unknown c++ exception"; + _os.write(reason); + _connection->sendResponse(&_os, _compress); + } + else + { + _connection->sendNoResponse(); } } - - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); -} - -void -IceInternal::IncomingAsync::__exception(const std::exception& ex) -{ - assert(!_finished); - _finished = true; - - if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - __warning(string("std::exception: ") + ex.what()); - } - - if(_response) + catch(const LocalException& ex) { - _os.endWriteEncaps(); - _os.b.resize(headerSize + 4); // Dispatch status position. - _os.write(static_cast<Byte>(DispatchUnknownException)); - ostringstream str; - str << "std::exception: " << ex.what(); - _os.write(str.str()); + _connection->exception(ex); } - - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); -} - -void -IceInternal::IncomingAsync::__exception() -{ - assert(!_finished); - _finished = true; - - if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + catch(const std::exception& ex) { - __warning("unknown c++ exception"); + UnknownException uex(__FILE__, __LINE__); + uex.unknown = string("std::exception: ") + ex.what(); + _connection->exception(uex); } - - if(_response) + catch(...) { - _os.endWriteEncaps(); - _os.b.resize(headerSize + 4); // Dispatch status position. - _os.write(static_cast<Byte>(DispatchUnknownException)); - string reason = "unknown c++ exception"; - _os.write(reason); + UnknownException uex(__FILE__, __LINE__); + uex.unknown = "unknown c++ exception"; + _connection->exception(uex); } - - // - // Must be called last, so that if an exception is raised, - // this function is definitely *not* called. - // - __finishInvoke(); } IceAsync::Ice::AMD_Object_ice_invoke::AMD_Object_ice_invoke(Incoming& in) : @@ -309,7 +410,6 @@ IceAsync::Ice::AMD_Object_ice_invoke::ice_response(bool ok, const vector<Byte>& __exception(ex); return; } - __response(ok); } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 221da646fc4..ddd280da4a7 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -4103,8 +4103,6 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_response(" << paramsDecl << ')'; C << sb; - C << nl << "if(!_finished)"; - C << sb; if(ret || !outParams.empty()) { C << nl << "try"; @@ -4124,13 +4122,10 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) } C << nl << "__response(true);"; C << eb; - C << eb; C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_exception(const ::Ice::Exception& ex)"; C << sb; - C << nl << "if(!_finished)"; - C << sb; if(throws.empty()) { C << nl << "__exception(ex);"; @@ -4160,23 +4155,16 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << eb; } C << eb; - C << eb; C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_exception(const ::std::exception& ex)"; C << sb; - C << nl << "if(!_finished)"; - C << sb; C << nl << "__exception(ex);"; C << eb; - C << eb; C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_exception()"; C << sb; - C << nl << "if(!_finished)"; - C << sb; C << nl << "__exception();"; C << eb; - C << eb; } diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 57bce9d9dfb..d0a078de015 100755 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -3861,8 +3861,6 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) _out << sp << nl << "public void ice_response" << spar << paramsAMD << epar; _out << sb; - _out << nl << "if(!_finished)"; - _out << sb; if(ret || !outParams.empty()) { _out << nl << "try"; @@ -3890,12 +3888,9 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) } _out << nl << "__response(true);"; _out << eb; - _out << eb; _out << sp << nl << "public void ice_exception(_System.Exception ex)"; _out << sb; - _out << nl << "if(!_finished)"; - _out << sb; if(throws.empty()) { _out << nl << "__exception(ex);"; @@ -3922,7 +3917,6 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) _out << eb; } _out << eb; - _out << eb; _out << eb; } diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 025b0a1a3c6..4761f56ad72 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -4834,8 +4834,6 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) out << sp << nl << "public void" << nl << "ice_response" << spar << paramsAMD << epar; out << sb; - out << nl << "if(!_finished)"; - out << sb; iter = 0; if(ret || !outParams.empty()) { @@ -4866,12 +4864,9 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) } out << nl << "__response(true);"; out << eb; - out << eb; out << sp << nl << "public void" << nl << "ice_exception(java.lang.Exception ex)"; out << sb; - out << nl << "if(!_finished)"; - out << sb; if(throws.empty()) { out << nl << "__exception(ex);"; @@ -4898,7 +4893,6 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) out << eb; } out << eb; - out << eb; out << eb; |