diff options
author | Michi Henning <michi@zeroc.com> | 2007-10-29 16:57:02 +1000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2007-10-29 16:57:02 +1000 |
commit | 3d0c83b386b37331de7069430049aec4944451c9 (patch) | |
tree | 4fb024d1b638e88c63ba655c6d4348211e588b59 /cpp/src/Ice/Incoming.cpp | |
parent | Merge branch 'master' of cvs:/home/git/ice (diff) | |
download | ice-3d0c83b386b37331de7069430049aec4944451c9.tar.bz2 ice-3d0c83b386b37331de7069430049aec4944451c9.tar.xz ice-3d0c83b386b37331de7069430049aec4944451c9.zip |
Bug 2522.
Diffstat (limited to 'cpp/src/Ice/Incoming.cpp')
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 83 |
1 files changed, 65 insertions, 18 deletions
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 391515df1ad..07af1086aa8 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -406,6 +406,7 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) try { + bool finishedException = false; try { if(servantManager) @@ -420,27 +421,38 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) } if(_locator) { - _servant = _locator->locate(_current, _cookie); + try + { + _servant = _locator->locate(_current, _cookie); + } + catch(const UserException& ex) + { + _os.write(ex); + replyStatus = replyUserException; + } } } } - if(!_servant) + if(replyStatus == replyOK) { - if(servantManager && servantManager->hasServant(_current.id)) + if(!_servant) { - replyStatus = replyFacetNotExist; + if(servantManager && servantManager->hasServant(_current.id)) + { + replyStatus = replyFacetNotExist; + } + else + { + replyStatus = replyObjectNotExist; + } } else { - replyStatus = replyObjectNotExist; - } - } - else - { - dispatchStatus = _servant->__dispatch(*this, _current); - if(dispatchStatus == DispatchUserException) - { - replyStatus = replyUserException; + dispatchStatus = _servant->__dispatch(*this, _current); + if(dispatchStatus == DispatchUserException) + { + replyStatus = replyUserException; + } } } } @@ -448,15 +460,50 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager) { if(_locator && _servant && dispatchStatus != DispatchAsync) { - _locator->finished(_current, _servant, _cookie); + try + { + _locator->finished(_current, _servant, _cookie); + } + catch(const UserException& ex) + { + // + // The operation may have already marshaled a reply; we must overwrite that reply. + // + _os.endWriteEncaps(); + _os.b.resize(headerSize + 5); // Byte following reply status. + _os.startWriteEncaps(); + _os.write(ex); + replyStatus = replyUserException; // Code below inserts the reply status. + finishedException = true; + } + catch(...) + { + throw; + } + } + if(!finishedException) + { + throw; } - - throw; } - if(_locator && _servant && dispatchStatus != DispatchAsync) + if(!finishedException && _locator && _servant && dispatchStatus != DispatchAsync) { - _locator->finished(_current, _servant, _cookie); + try + { + _locator->finished(_current, _servant, _cookie); + } + catch(const UserException& ex) + { + // + // The operation may have already marshaled a reply; we must overwrite that reply. + // + _os.endWriteEncaps(); + _os.b.resize(headerSize + 5); // Byte following reply status. + _os.startWriteEncaps(); + _os.write(ex); + replyStatus = replyUserException; // Code below inserts the reply status. + } } } catch(const std::exception& ex) |