From 9cb5db6efbf5ff00b788b716c1150f519d858ca3 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Thu, 7 Mar 2024 19:16:00 -0500 Subject: [PATCH 1/4] Remove system exceptions --- cpp/include/Ice/Exception.h | 32 ------------------------ cpp/src/Ice/CollocatedRequestHandler.cpp | 8 ------ cpp/src/Ice/CollocatedRequestHandler.h | 1 - cpp/src/Ice/ConnectionI.cpp | 6 ----- cpp/src/Ice/ConnectionI.h | 1 - cpp/src/Ice/Exception.cpp | 21 ---------------- cpp/src/Ice/Incoming.cpp | 9 ------- cpp/src/Ice/ResponseHandler.h | 1 - cpp/test/Ice/retry/AllTests.cpp | 30 ---------------------- cpp/test/Ice/retry/SystemFailure.h | 24 ------------------ cpp/test/Ice/retry/Test.ice | 1 - cpp/test/Ice/retry/TestI.cpp | 7 ------ cpp/test/Ice/retry/TestI.h | 1 - 13 files changed, 142 deletions(-) delete mode 100644 cpp/test/Ice/retry/SystemFailure.h diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h index 8626337386c..acf93667cef 100644 --- a/cpp/include/Ice/Exception.h +++ b/cpp/include/Ice/Exception.h @@ -79,38 +79,6 @@ namespace Ice virtual void _readImpl(::Ice::InputStream*) {} /// \endcond }; - - /** - * Base class for all Ice system exceptions. - * - * System exceptions are currently Ice internal, non-documented - * exceptions. - * \headerfile Ice/Ice.h - */ - class ICE_API SystemException : public IceUtil::Exception - { - public: - /** - * The file and line number are required for all local exceptions. - * @param file The file name in which the exception was raised, typically __FILE__. - * @param line The line number at which the exception was raised, typically __LINE__. - */ - SystemException(const char* file, int line); - SystemException(const SystemException&) = default; - virtual ~SystemException(); - - /** - * Polymorphically clones this exception. - * @return A shallow copy of this exception. - */ - std::unique_ptr ice_clone() const; - - /** - * Obtains the Slice type ID of this exception. - * @return The fully-scoped type ID. - */ - static std::string_view ice_staticId(); - }; } namespace IceInternal diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp index 6551c9a84c4..d57226017ba 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.cpp +++ b/cpp/src/Ice/CollocatedRequestHandler.cpp @@ -246,14 +246,6 @@ CollocatedRequestHandler::sendNoResponse() _adapter->decDirectCount(); } -bool -CollocatedRequestHandler::systemException(int32_t requestId, exception_ptr ex, bool amd) -{ - handleException(requestId, ex, amd); - _adapter->decDirectCount(); - return true; -} - void CollocatedRequestHandler::invokeException(int32_t requestId, exception_ptr ex, int /*invokeNum*/, bool amd) { diff --git a/cpp/src/Ice/CollocatedRequestHandler.h b/cpp/src/Ice/CollocatedRequestHandler.h index e50410ac9a3..f2dceeb1436 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.h +++ b/cpp/src/Ice/CollocatedRequestHandler.h @@ -37,7 +37,6 @@ namespace IceInternal virtual void sendResponse(std::int32_t, Ice::OutputStream*, std::uint8_t, bool); virtual void sendNoResponse(); - virtual bool systemException(std::int32_t, std::exception_ptr, bool); virtual void invokeException(std::int32_t, std::exception_ptr, int, bool); virtual Ice::ConnectionIPtr getConnection(); diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index 2949c051096..7edfbb9bd39 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -1169,12 +1169,6 @@ Ice::ConnectionI::sendNoResponse() } } -bool -Ice::ConnectionI::systemException(int32_t, std::exception_ptr, bool /*amd*/) -{ - return false; // System exceptions aren't marshalled. -} - void Ice::ConnectionI::invokeException(int32_t, exception_ptr ex, int invokeNum, bool /*amd*/) { diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index b13a38a5c90..94a583300d0 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -176,7 +176,6 @@ namespace Ice virtual void sendResponse(std::int32_t, Ice::OutputStream*, std::uint8_t, bool); virtual void sendNoResponse(); - virtual bool systemException(std::int32_t, std::exception_ptr, bool); virtual void invokeException(std::int32_t, std::exception_ptr, int, bool); IceInternal::EndpointIPtr endpoint() const; diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp index 9b04da433e6..a37cf0e8892 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -132,27 +132,6 @@ Ice::LocalException::ice_staticId() return localException_ids[0]; } -Ice::SystemException::SystemException(const char* file, int line) : Exception(file, line) {} - -Ice::SystemException::~SystemException() {} - -unique_ptr -Ice::SystemException::ice_clone() const -{ - return unique_ptr(static_cast(ice_cloneImpl())); -} - -namespace -{ - const string systemException_ids[] = {"::Ice::SystemException"}; -} - -std::string_view -Ice::SystemException::ice_staticId() -{ - return systemException_ids[0]; -} - void Ice::InitializationException::ice_print(ostream& out) const { diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index d6f7e1bee1e..4a50a078e0c 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -396,15 +396,6 @@ Incoming::handleException(std::exception_ptr exc, bool amd) } catch (const Exception& ex) { - if (dynamic_cast(&ex)) - { - if (_responseHandler->systemException(_current.requestId, exc, amd)) - { - return; - } - // else, keep going - } - if (_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) { warning(ex); diff --git a/cpp/src/Ice/ResponseHandler.h b/cpp/src/Ice/ResponseHandler.h index f7d6cd58e30..37e1f96913c 100644 --- a/cpp/src/Ice/ResponseHandler.h +++ b/cpp/src/Ice/ResponseHandler.h @@ -22,7 +22,6 @@ namespace IceInternal public: virtual void sendResponse(std::int32_t, Ice::OutputStream*, std::uint8_t, bool) = 0; virtual void sendNoResponse() = 0; - virtual bool systemException(std::int32_t, std::exception_ptr, bool) = 0; virtual void invokeException(std::int32_t, std::exception_ptr, int, bool) = 0; }; } diff --git a/cpp/test/Ice/retry/AllTests.cpp b/cpp/test/Ice/retry/AllTests.cpp index 182a6dba315..14a50f7e849 100644 --- a/cpp/test/Ice/retry/AllTests.cpp +++ b/cpp/test/Ice/retry/AllTests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include using namespace std; using namespace Test; @@ -221,35 +220,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const Ice::CommunicatorPtr& c testRetryCount(0); cout << "ok" << endl; - if (!retry1->ice_getConnection()) - { - testInvocationCount(-1); - cout << "testing system exception... " << flush; - try - { - retry1->opSystemException(); - test(false); - } - catch (const SystemFailure&) - { - } - testInvocationCount(1); - testFailureCount(1); - testRetryCount(0); - try - { - retry1->opSystemExceptionAsync().get(); - test(false); - } - catch (const SystemFailure&) - { - } - testInvocationCount(1); - testFailureCount(1); - testRetryCount(0); - cout << "ok" << endl; - } - { cout << "testing invocation timeout and retries... " << flush; retry2 = RetryPrx(communicator2, retry1->ice_toString()); diff --git a/cpp/test/Ice/retry/SystemFailure.h b/cpp/test/Ice/retry/SystemFailure.h deleted file mode 100644 index 2b9ae2a6867..00000000000 --- a/cpp/test/Ice/retry/SystemFailure.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#ifndef SYSTEMFAILURE_H -#define SYSTEMFAILURE_H - -#include - -class SystemFailure : public Ice::SystemException -{ -public: - SystemFailure(const char* file, int line) : Ice::SystemException(file, line) {} - - SystemFailure(const SystemFailure& ex) : Ice::SystemException(ex.ice_file(), ex.ice_line()) {} - - virtual std::string ice_id() const { return "SystemFailure"; } - - virtual IceUtil::Exception* ice_cloneImpl() const { return new SystemFailure(*this); } - - virtual void ice_throw() const { throw SystemFailure(*this); } -}; - -#endif diff --git a/cpp/test/Ice/retry/Test.ice b/cpp/test/Ice/retry/Test.ice index de03d65aaf5..619df58edac 100644 --- a/cpp/test/Ice/retry/Test.ice +++ b/cpp/test/Ice/retry/Test.ice @@ -13,7 +13,6 @@ interface Retry idempotent int opIdempotent(int c); void opNotIdempotent(); - void opSystemException(); idempotent void sleep(int delay); diff --git a/cpp/test/Ice/retry/TestI.cpp b/cpp/test/Ice/retry/TestI.cpp index 13658b732f6..22a4f05e840 100644 --- a/cpp/test/Ice/retry/TestI.cpp +++ b/cpp/test/Ice/retry/TestI.cpp @@ -5,7 +5,6 @@ #include #include -#include #include using namespace std; @@ -53,12 +52,6 @@ RetryI::opNotIdempotent(const Ice::Current&) throw Ice::ConnectionLostException(__FILE__, __LINE__); } -void -RetryI::opSystemException(const Ice::Current&) -{ - throw SystemFailure(__FILE__, __LINE__); -} - void RetryI::sleep(int delay, const Ice::Current&) { diff --git a/cpp/test/Ice/retry/TestI.h b/cpp/test/Ice/retry/TestI.h index 7cd1eb4ee1f..7993a52f5aa 100644 --- a/cpp/test/Ice/retry/TestI.h +++ b/cpp/test/Ice/retry/TestI.h @@ -15,7 +15,6 @@ class RetryI : public Test::Retry virtual void op(bool, const Ice::Current&); virtual int opIdempotent(int, const Ice::Current&); virtual void opNotIdempotent(const Ice::Current&); - virtual void opSystemException(const Ice::Current&); virtual void sleep(int, const Ice::Current&); virtual void shutdown(const Ice::Current&); From 6dfb854f5bbae0b68471faaefa8bc489858682de Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Thu, 7 Mar 2024 19:28:39 -0500 Subject: [PATCH 2/4] Initial removal of amd parameter --- cpp/src/Ice/CollocatedRequestHandler.cpp | 40 +++++------------------- cpp/src/Ice/CollocatedRequestHandler.h | 6 ++-- cpp/src/Ice/ConnectionI.cpp | 6 ++-- cpp/src/Ice/ConnectionI.h | 4 +-- cpp/src/Ice/Incoming.cpp | 16 +++++----- cpp/src/Ice/ResponseHandler.h | 4 +-- 6 files changed, 26 insertions(+), 50 deletions(-) diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp index d57226017ba..564707ac8b5 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.cpp +++ b/cpp/src/Ice/CollocatedRequestHandler.cpp @@ -188,7 +188,7 @@ CollocatedRequestHandler::invokeAsyncRequest(OutgoingAsyncBase* outAsync, int ba } void -CollocatedRequestHandler::sendResponse(int32_t requestId, OutputStream* os, uint8_t, bool amd) +CollocatedRequestHandler::sendResponse(int32_t requestId, OutputStream* os, uint8_t) { OutgoingAsyncBasePtr outAsync; { @@ -222,19 +222,7 @@ CollocatedRequestHandler::sendResponse(int32_t requestId, OutputStream* os, uint if (outAsync) { - // - // If called from an AMD dispatch, invoke asynchronously - // the completion callback since this might be called from - // the user code. - // - if (amd) - { - outAsync->invokeResponseAsync(); - } - else - { - outAsync->invokeResponse(); - } + outAsync->invokeResponseAsync(); } _adapter->decDirectCount(); @@ -247,9 +235,9 @@ CollocatedRequestHandler::sendNoResponse() } void -CollocatedRequestHandler::invokeException(int32_t requestId, exception_ptr ex, int /*invokeNum*/, bool amd) +CollocatedRequestHandler::invokeException(int32_t requestId, exception_ptr ex, int /*invokeNum*/) { - handleException(requestId, ex, amd); + handleException(requestId, ex); _adapter->decDirectCount(); } @@ -330,7 +318,7 @@ CollocatedRequestHandler::invokeAll(OutputStream* os, int32_t requestId, int32_t } catch (const ObjectAdapterDeactivatedException&) { - handleException(requestId, current_exception(), false); + handleException(requestId, current_exception()); break; } @@ -342,14 +330,14 @@ CollocatedRequestHandler::invokeAll(OutputStream* os, int32_t requestId, int32_t } catch (const LocalException&) { - invokeException(requestId, current_exception(), invokeNum, false); // Fatal invocation exception + invokeException(requestId, current_exception(), invokeNum); // Fatal invocation exception } _adapter->decDirectCount(); } void -CollocatedRequestHandler::handleException(int requestId, std::exception_ptr ex, bool amd) +CollocatedRequestHandler::handleException(int requestId, std::exception_ptr ex) { if (requestId == 0) { @@ -373,18 +361,6 @@ CollocatedRequestHandler::handleException(int requestId, std::exception_ptr ex, if (outAsync) { - // - // If called from an AMD dispatch, invoke asynchronously - // the completion callback since this might be called from - // the user code. - // - if (amd) - { - outAsync->invokeExceptionAsync(); - } - else - { - outAsync->invokeException(); - } + outAsync->invokeExceptionAsync(); } } diff --git a/cpp/src/Ice/CollocatedRequestHandler.h b/cpp/src/Ice/CollocatedRequestHandler.h index f2dceeb1436..3b8907832c0 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.h +++ b/cpp/src/Ice/CollocatedRequestHandler.h @@ -35,9 +35,9 @@ namespace IceInternal virtual void asyncRequestCanceled(const OutgoingAsyncBasePtr&, std::exception_ptr); - virtual void sendResponse(std::int32_t, Ice::OutputStream*, std::uint8_t, bool); + virtual void sendResponse(std::int32_t, Ice::OutputStream*, std::uint8_t); virtual void sendNoResponse(); - virtual void invokeException(std::int32_t, std::exception_ptr, int, bool); + virtual void invokeException(std::int32_t, std::exception_ptr, int); virtual Ice::ConnectionIPtr getConnection(); virtual Ice::ConnectionIPtr waitForConnection(); @@ -54,7 +54,7 @@ namespace IceInternal } private: - void handleException(std::int32_t, std::exception_ptr, bool); + void handleException(std::int32_t, std::exception_ptr); const std::shared_ptr _adapter; const bool _dispatcher; diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index 7edfbb9bd39..07dd772b47d 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -1097,7 +1097,7 @@ Ice::ConnectionI::asyncRequestCanceled(const OutgoingAsyncBasePtr& outAsync, exc } void -Ice::ConnectionI::sendResponse(int32_t, OutputStream* os, uint8_t compressFlag, bool /*amd*/) +Ice::ConnectionI::sendResponse(int32_t, OutputStream* os, uint8_t compressFlag) { std::unique_lock lock(_mutex); assert(_state > StateNotValidated); @@ -1170,7 +1170,7 @@ Ice::ConnectionI::sendNoResponse() } void -Ice::ConnectionI::invokeException(int32_t, exception_ptr ex, int invokeNum, bool /*amd*/) +Ice::ConnectionI::invokeException(int32_t, exception_ptr ex, int invokeNum) { // // Fatal exception while invoking a request. Since sendResponse/sendNoResponse isn't @@ -3389,7 +3389,7 @@ Ice::ConnectionI::invokeAll( } catch (const LocalException&) { - invokeException(requestId, current_exception(), invokeNum, false); // Fatal invocation exception + invokeException(requestId, current_exception(), invokeNum); // Fatal invocation exception } } diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index 94a583300d0..8df5e5c341d 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -174,9 +174,9 @@ namespace Ice virtual void asyncRequestCanceled(const IceInternal::OutgoingAsyncBasePtr&, std::exception_ptr); - virtual void sendResponse(std::int32_t, Ice::OutputStream*, std::uint8_t, bool); + virtual void sendResponse(std::int32_t, Ice::OutputStream*, std::uint8_t); virtual void sendNoResponse(); - virtual void invokeException(std::int32_t, std::exception_ptr, int, bool); + virtual void invokeException(std::int32_t, std::exception_ptr, int); IceInternal::EndpointIPtr endpoint() const; IceInternal::ConnectorPtr connector() const; diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 4a50a078e0c..2561047132b 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -148,7 +148,7 @@ Incoming::response(bool amd) if (_isTwoWay) { _observer.reply(static_cast(_os.b.size() - headerSize - 4)); - _responseHandler->sendResponse(_current.requestId, &_os, _compress, amd); + _responseHandler->sendResponse(_current.requestId, &_os, _compress); } else { @@ -158,7 +158,7 @@ Incoming::response(bool amd) catch (const LocalException&) { _responseHandler->invokeException( - _current.requestId, current_exception(), 1, amd); // Fatal invocation exception + _current.requestId, current_exception(), 1); // Fatal invocation exception } _observer.detach(); @@ -179,7 +179,7 @@ Incoming::exception(std::exception_ptr exc, bool amd) catch (const LocalException&) { _responseHandler->invokeException( - _current.requestId, current_exception(), 1, amd); // Fatal invocation exception + _current.requestId, current_exception(), 1); // Fatal invocation exception } } @@ -286,7 +286,7 @@ Incoming::servantLocatorFinished(bool amd) } void -Incoming::handleException(std::exception_ptr exc, bool amd) +Incoming::handleException(std::exception_ptr exc, bool /*amd*/) { assert(_responseHandler); @@ -364,7 +364,7 @@ Incoming::handleException(std::exception_ptr exc, bool amd) _os.write(rfe.operation, false); _observer.reply(static_cast(_os.b.size() - headerSize - 4)); - _responseHandler->sendResponse(_current.requestId, &_os, _compress, amd); + _responseHandler->sendResponse(_current.requestId, &_os, _compress); } else { @@ -387,7 +387,7 @@ Incoming::handleException(std::exception_ptr exc, bool amd) _os.write(uex); _os.endEncapsulation(); _observer.reply(static_cast(_os.b.size() - headerSize - 4)); - _responseHandler->sendResponse(_current.requestId, &_os, _compress, amd); + _responseHandler->sendResponse(_current.requestId, &_os, _compress); } else { @@ -460,7 +460,7 @@ Incoming::handleException(std::exception_ptr exc, bool amd) } _observer.reply(static_cast(_os.b.size() - headerSize - 4)); - _responseHandler->sendResponse(_current.requestId, &_os, _compress, amd); + _responseHandler->sendResponse(_current.requestId, &_os, _compress); } else { @@ -491,7 +491,7 @@ Incoming::handleException(std::exception_ptr exc, bool amd) _os.write(str.str(), false); _observer.reply(static_cast(_os.b.size() - headerSize - 4)); - _responseHandler->sendResponse(_current.requestId, &_os, _compress, amd); + _responseHandler->sendResponse(_current.requestId, &_os, _compress); } else { diff --git a/cpp/src/Ice/ResponseHandler.h b/cpp/src/Ice/ResponseHandler.h index 37e1f96913c..168f64c7017 100644 --- a/cpp/src/Ice/ResponseHandler.h +++ b/cpp/src/Ice/ResponseHandler.h @@ -20,9 +20,9 @@ namespace IceInternal class ResponseHandler : public EnableSharedFromThis { public: - virtual void sendResponse(std::int32_t, Ice::OutputStream*, std::uint8_t, bool) = 0; + virtual void sendResponse(std::int32_t, Ice::OutputStream*, std::uint8_t) = 0; virtual void sendNoResponse() = 0; - virtual void invokeException(std::int32_t, std::exception_ptr, int, bool) = 0; + virtual void invokeException(std::int32_t, std::exception_ptr, int) = 0; }; } From 6002034a751babc1b0a9979a8b4392a19976e270 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Thu, 7 Mar 2024 19:42:02 -0500 Subject: [PATCH 3/4] Cleanup --- cpp/include/Ice/Incoming.h | 10 +++++----- cpp/src/Ice/Incoming.cpp | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cpp/include/Ice/Incoming.h b/cpp/include/Ice/Incoming.h index 153ebbd6a62..3414be1dbb0 100644 --- a/cpp/include/Ice/Incoming.h +++ b/cpp/include/Ice/Incoming.h @@ -43,9 +43,6 @@ namespace IceInternal void writeParamEncaps(const std::uint8_t*, std::int32_t, bool ok); void setMarshaledResult(Ice::MarshaledResult&&); - void response(bool amd); - void exception(std::exception_ptr, bool amd); - void setFormat(Ice::FormatType format) { _format = format; } void invoke(const ServantManagerPtr&, Ice::InputStream*); @@ -89,12 +86,15 @@ namespace IceInternal private: void setResponseSent(); + void sendResponse(); + void sendException(std::exception_ptr); + void warning(const Ice::Exception&) const; void warning(std::exception_ptr) const; - bool servantLocatorFinished(bool amd); + bool servantLocatorFinished(); - void handleException(std::exception_ptr, bool amd); + void handleException(std::exception_ptr); Ice::Current _current; std::shared_ptr _servant; diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 2561047132b..d64ac71b58f 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -135,11 +135,11 @@ Incoming::setMarshaledResult(Ice::MarshaledResult&& result) } void -Incoming::response(bool amd) +Incoming::sendResponse() { try { - if (_locator && !servantLocatorFinished(amd)) + if (_locator && !servantLocatorFinished()) { return; } @@ -166,15 +166,15 @@ Incoming::response(bool amd) } void -Incoming::exception(std::exception_ptr exc, bool amd) +Incoming::sendException(std::exception_ptr exc) { try { - if (_locator && !servantLocatorFinished(amd)) + if (_locator && !servantLocatorFinished()) { return; } - handleException(exc, amd); + handleException(exc); } catch (const LocalException&) { @@ -270,7 +270,7 @@ Incoming::warning(std::exception_ptr ex) const } bool -Incoming::servantLocatorFinished(bool amd) +Incoming::servantLocatorFinished() { assert(_locator && _servant); try @@ -280,13 +280,13 @@ Incoming::servantLocatorFinished(bool amd) } catch (...) { - handleException(current_exception(), amd); + handleException(current_exception()); } return false; } void -Incoming::handleException(std::exception_ptr exc, bool /*amd*/) +Incoming::handleException(std::exception_ptr exc) { assert(_responseHandler); @@ -585,7 +585,7 @@ Incoming::invoke(const ServantManagerPtr& servantManager, InputStream* stream) catch (...) { skipReadParams(); // Required for batch requests. - handleException(current_exception(), false); + handleException(current_exception()); return; } } @@ -608,7 +608,7 @@ Incoming::invoke(const ServantManagerPtr& servantManager, InputStream* stream) catch (...) { skipReadParams(); // Required for batch requests - handleException(current_exception(), false); + handleException(current_exception()); return; } } @@ -619,14 +619,14 @@ Incoming::invoke(const ServantManagerPtr& servantManager, InputStream* stream) if (_servant->_iceDispatch(*this)) { // If the request was dispatched synchronously, send the response. - response(false); // amd: false + sendResponse(); } } catch (...) { // An async dispatch is not allowed to throw any exception because it moves "this" memory into a new Incoming // object. - exception(current_exception(), false); // amd: false + sendException(current_exception()); } } @@ -634,14 +634,14 @@ void Incoming::completed() { setResponseSent(); - response(true); // amd: true + sendResponse(); } void Incoming::completed(exception_ptr ex) { setResponseSent(); - exception(ex, true); // amd: true + sendException(ex); } void From 2cdc95bb1066925f014da8e36a9d63afca02c8bd Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Thu, 7 Mar 2024 20:04:41 -0500 Subject: [PATCH 4/4] Cleanup --- cpp/src/Ice/CollocatedRequestHandler.cpp | 6 ++++++ cpp/src/Ice/OutgoingAsync.cpp | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp index 564707ac8b5..77a72d087e4 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.cpp +++ b/cpp/src/Ice/CollocatedRequestHandler.cpp @@ -222,6 +222,9 @@ CollocatedRequestHandler::sendResponse(int32_t requestId, OutputStream* os, uint if (outAsync) { + // We invoke the response using a thread-pool thread. If the invocation is a lambda async invocation, we want + // the callbacks to execute in a thread-pool thread - never in the application thread that sent the response + // via AMD. outAsync->invokeResponseAsync(); } @@ -361,6 +364,9 @@ CollocatedRequestHandler::handleException(int requestId, std::exception_ptr ex) if (outAsync) { + // We invoke the exception using a thread-pool thread. If the invocation is a lambda async invocation, we want + // the callbacks to execute in a thread-pool thread - never in the application thread that sent the exception + // via AMD. outAsync->invokeExceptionAsync(); } } diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index aeff6f53e32..fd85f9aad08 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -176,7 +176,6 @@ OutgoingAsyncBase::invokeResponse() } catch (...) { - // TODO: make handleException noexcept // With the lambda async API, lambdaInvokeResponse throws _before_ reaching the application's response when the // unmarshaling fails or when the response contains a user exception. We want to call handleInvokeException // in this situation.