diff options
Diffstat (limited to 'TAO/tao/Synch_Invocation.cpp')
-rw-r--r-- | TAO/tao/Synch_Invocation.cpp | 197 |
1 files changed, 83 insertions, 114 deletions
diff --git a/TAO/tao/Synch_Invocation.cpp b/TAO/tao/Synch_Invocation.cpp index d1b4d7cc30d..34e957bdbba 100644 --- a/TAO/tao/Synch_Invocation.cpp +++ b/TAO/tao/Synch_Invocation.cpp @@ -14,6 +14,7 @@ #include "tao/Messaging_SyncScopeC.h" #include "tao/ORB_Core.h" #include "tao/Service_Context.h" +#include "tao/SystemException.h" #if TAO_HAS_INTERCEPTORS == 1 # include "tao/PortableInterceptorC.h" @@ -51,7 +52,6 @@ namespace TAO Invocation_Status Synch_Twoway_Invocation::remote_twoway (ACE_Time_Value *max_wait_time) - ACE_THROW_SPEC ((CORBA::Exception)) { ACE_Countdown_Time countdown (max_wait_time); @@ -65,18 +65,18 @@ namespace TAO #if TAO_HAS_INTERCEPTORS == 1 // Start the interception point here.. - s = - this->send_request_interception (); + s = this->send_request_interception (); if (s != TAO_INVOKE_SUCCESS) return s; -#endif /*TAO_HAS_INTERCEPTORS */ // We have started the interception flow. We need to call the // ending interception flow if things go wrong. The purpose of the // try block is to do just this. try { +#endif /*TAO_HAS_INTERCEPTORS */ + TAO_OutputCDR &cdr = this->resolver_.transport ()->out_stream (); cdr.message_attributes (this->details_.request_id (), @@ -84,12 +84,9 @@ namespace TAO TAO_Transport::TAO_TWOWAY_REQUEST, max_wait_time); - this->write_header (tspec, - cdr - ); + this->write_header (tspec, cdr); - this->marshal_data (cdr - ); + this->marshal_data (cdr); // Register a reply dispatcher for this invocation. Use the // preallocated reply dispatcher. @@ -104,19 +101,14 @@ namespace TAO // we close the connection? this->resolver_.transport ()->close_connection (); - ACE_THROW_RETURN ( - CORBA::INTERNAL ( - 0, - CORBA::COMPLETED_NO), - s); + throw ::CORBA::INTERNAL (0, CORBA::COMPLETED_NO); } countdown.update (); s = this->send_message (cdr, TAO_Transport::TAO_TWOWAY_REQUEST, - max_wait_time - ); + max_wait_time); #if TAO_HAS_INTERCEPTORS == 1 // @@NOTE: Too much code repetition. @@ -125,13 +117,12 @@ namespace TAO // before we leave. if (s == TAO_INVOKE_RESTART) { - const Invocation_Status tmp = - this->receive_other_interception (); + Invocation_Status const tmp = this->receive_other_interception (); if (tmp != TAO_INVOKE_SUCCESS) s = tmp; } -#endif /*TAO_HAS_INTERCEPTORS */ +#endif /* TAO_HAS_INTERCEPTORS */ if (s != TAO_INVOKE_SUCCESS) return s; @@ -161,23 +152,18 @@ namespace TAO // (explicitly coded) handlers called. We assume a POSIX.1c/C/C++ // environment. - s = - this->wait_for_reply (max_wait_time, - rd, - dispatch_guard - ); + s = this->wait_for_reply (max_wait_time, rd, dispatch_guard); #if TAO_HAS_INTERCEPTORS == 1 if (s == TAO_INVOKE_RESTART) { - Invocation_Status const tmp = - this->receive_other_interception (); + Invocation_Status const tmp = this->receive_other_interception (); // Push the latest values for the return.. if (tmp != TAO_INVOKE_SUCCESS) s = tmp; } -#endif /*TAO_HAS_INTERCEPTORS */ +#endif /* TAO_HAS_INTERCEPTORS */ if (s != TAO_INVOKE_SUCCESS) return s; @@ -185,9 +171,7 @@ namespace TAO // What happens when the above call returns an error through // the return value? That would be bogus as per the contract // in the interface. The call violated the contract - - s = this->check_reply_status (rd - ); + s = this->check_reply_status (rd); // For some strategies one may want to release the transport // back to cache after receiving the reply. @@ -206,14 +190,9 @@ namespace TAO } if (tmp != TAO_INVOKE_SUCCESS) s = tmp; -#endif /*TAO_HAS_INTERCEPTORS */ - - if (s != TAO_INVOKE_SUCCESS) - return s; } catch ( ::CORBA::Exception& ex) { -#if TAO_HAS_INTERCEPTORS == 1 PortableInterceptor::ReplyStatus const status = this->handle_any_exception (&ex); @@ -222,11 +201,23 @@ namespace TAO s = TAO_INVOKE_RESTART; else if (status == PortableInterceptor::SYSTEM_EXCEPTION || status == PortableInterceptor::USER_EXCEPTION) -#else - ACE_UNUSED_ARG (ex); -#endif /*TAO_HAS_INTERCEPTORS*/ throw; } + catch (...) + { + // Notify interceptors of non-CORBA exception, and propagate + // that exception to the caller. + + PortableInterceptor::ReplyStatus const st = + this->handle_all_exception (); + + if (st == PortableInterceptor::LOCATION_FORWARD || + st == PortableInterceptor::TRANSPORT_RETRY) + s = TAO_INVOKE_RESTART; + else + throw; + } +#endif /* TAO_HAS_INTERCEPTORS */ return s; } @@ -235,7 +226,6 @@ namespace TAO Synch_Twoway_Invocation::wait_for_reply (ACE_Time_Value *max_wait_time, TAO_Synch_Reply_Dispatcher &rd, TAO_Bind_Dispatcher_Guard &bd) - ACE_THROW_SPEC ((CORBA::SystemException)) { /* * Precondition: The call went to the remote @@ -245,7 +235,7 @@ namespace TAO * exception. Success alone is returned through the return value. */ - const int reply_error = + int const reply_error = this->resolver_.transport ()->wait_strategy ()->wait (max_wait_time, rd); if (TAO_debug_level > 0 && max_wait_time != 0) @@ -294,12 +284,11 @@ namespace TAO { // Just a timeout with completed_maybe, don't close // the connection or anything - ACE_THROW_RETURN (CORBA::TIMEOUT ( - CORBA::SystemException::_tao_minor_code ( - TAO_TIMEOUT_RECV_MINOR_CODE, - errno), - CORBA::COMPLETED_MAYBE), - TAO_INVOKE_FAILURE); + throw ::CORBA::TIMEOUT ( + CORBA::SystemException::_tao_minor_code ( + TAO_TIMEOUT_RECV_MINOR_CODE, + errno), + CORBA::COMPLETED_MAYBE); } } else @@ -312,8 +301,7 @@ namespace TAO return this->orb_core ()->service_raise_comm_failure ( this->details_.request_service_context ().service_info (), - this->resolver_.profile () - ); + this->resolver_.profile ()); } catch (const ::CORBA::Exception&) @@ -328,8 +316,7 @@ namespace TAO } Invocation_Status - Synch_Twoway_Invocation::check_reply_status (TAO_Synch_Reply_Dispatcher &rd - ) + Synch_Twoway_Invocation::check_reply_status (TAO_Synch_Reply_Dispatcher &rd) { /* * Precondition: We probably got a reply. <ACE_Thread::self> is @@ -340,8 +327,7 @@ namespace TAO * returning a restart since that is what needed to be done by the * callee. */ - TAO_InputCDR &cdr = - rd.reply_cdr (); + TAO_InputCDR &cdr = rd.reply_cdr (); // Set the translators this->resolver_.transport ()->assign_translators (&cdr, 0); @@ -355,27 +341,22 @@ namespace TAO { case TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION: { - Reply_Guard mon (this, - TAO_INVOKE_FAILURE); + Reply_Guard mon (this, TAO_INVOKE_FAILURE); if (this->details_.demarshal_args (cdr) == false) { - ACE_THROW_RETURN (CORBA::MARSHAL (), - TAO_INVOKE_FAILURE); + throw ::CORBA::MARSHAL (); } mon.set_status (TAO_INVOKE_SUCCESS); } break; case TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD: - return this->location_forward (cdr - ); + return this->location_forward (cdr); case TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD_PERM: { // Unmarshal the location forward object and set the // variable this->forward_to_. - Invocation_Status const s - = this->location_forward (cdr - ); + Invocation_Status const s = this->location_forward (cdr); if (s != TAO_INVOKE_FAILURE) { // de-marshalling of permanent object reference was successfull @@ -392,24 +373,20 @@ namespace TAO "TAO (%P|%t) - Synch_Twoway_Invocation::" "check_reply_status: unexpected LOCATION_FORWARD_PERM reply\n")); - ACE_THROW_RETURN (CORBA::INTERNAL (0, CORBA::COMPLETED_NO), - TAO_INVOKE_FAILURE); + throw ::CORBA::INTERNAL (0, CORBA::COMPLETED_NO); } } return s; } case TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION: - return this->handle_user_exception (cdr - ); + return this->handle_user_exception (cdr); case TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION: - return this->handle_system_exception (cdr - ); + return this->handle_system_exception (cdr); case TAO_PLUGGABLE_MESSAGE_NEEDS_ADDRESSING_MODE: { - Reply_Guard mon (this, - TAO_INVOKE_FAILURE); + Reply_Guard mon (this, TAO_INVOKE_FAILURE); // We have received a message with a request to change the // addressing mode. First let us read the mode that the // server/agent asks for. @@ -419,15 +396,12 @@ namespace TAO { // Could not demarshal the addressing disposition, raise an local // CORBA::MARSHAL - ACE_THROW_RETURN (CORBA::MARSHAL (0, - CORBA::COMPLETED_MAYBE), - TAO_INVOKE_FAILURE); + throw ::CORBA::MARSHAL (0, CORBA::COMPLETED_MAYBE); } // Now set this addressing mode in the profile, so that // the next invocation need not go through this. - this->resolver_.profile ()->addressing_mode (addr_mode - ); + this->resolver_.profile ()->addressing_mode (addr_mode); mon.set_status (TAO_INVOKE_RESTART); @@ -440,10 +414,8 @@ namespace TAO Invocation_Status Synch_Twoway_Invocation::location_forward (TAO_InputCDR &inp_stream) - ACE_THROW_SPEC ((CORBA::SystemException)) { - Reply_Guard mon (this, - TAO_INVOKE_FAILURE); + Reply_Guard mon (this, TAO_INVOKE_FAILURE); if (TAO_debug_level > 3) { @@ -456,12 +428,11 @@ namespace TAO if ((inp_stream >> fwd) == 0) { - ACE_THROW_RETURN (CORBA::MARSHAL ( - CORBA::SystemException::_tao_minor_code ( - TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE, - errno), - CORBA::COMPLETED_NO), - TAO_INVOKE_FAILURE); + throw ::CORBA::MARSHAL ( + CORBA::SystemException::_tao_minor_code ( + TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE, + errno), + CORBA::COMPLETED_NO); } this->forwarded_reference (fwd.in ()); @@ -473,7 +444,6 @@ namespace TAO Invocation_Status Synch_Twoway_Invocation::handle_user_exception (TAO_InputCDR &cdr) - ACE_THROW_SPEC ((CORBA::Exception)) { Reply_Guard mon (this, TAO_INVOKE_FAILURE); @@ -490,9 +460,7 @@ namespace TAO { // Could not demarshal the exception id, raise an local // CORBA::MARSHAL - ACE_THROW_RETURN (CORBA::MARSHAL (0, - CORBA::COMPLETED_MAYBE), - TAO_INVOKE_FAILURE); + throw ::CORBA::MARSHAL (0, CORBA::COMPLETED_MAYBE); } CORBA::Exception *exception = this->details_.corba_exception (buf.in ()); @@ -523,7 +491,6 @@ namespace TAO Invocation_Status Synch_Twoway_Invocation::handle_system_exception (TAO_InputCDR &cdr) - ACE_THROW_SPEC ((CORBA::SystemException)) { Reply_Guard mon (this, TAO_INVOKE_FAILURE); @@ -538,27 +505,22 @@ namespace TAO { // Could not demarshal the exception id, raise an local // CORBA::MARSHAL - ACE_THROW_RETURN (CORBA::MARSHAL (0, - CORBA::COMPLETED_MAYBE), - TAO_INVOKE_FAILURE); + throw ::CORBA::MARSHAL (0, CORBA::COMPLETED_MAYBE); } CORBA::ULong minor = 0; CORBA::ULong completion = 0; - if ((cdr >> minor) == 0 - || (cdr >> completion) == 0) + if ((cdr >> minor) == 0 || (cdr >> completion) == 0) { - ACE_THROW_RETURN (CORBA::MARSHAL (0, - CORBA::COMPLETED_MAYBE), - TAO_INVOKE_FAILURE); + throw ::CORBA::MARSHAL (0, CORBA::COMPLETED_MAYBE); } // Special handling for non-fatal system exceptions. // // Note that we are careful to retain "at most once" semantics. if ((ACE_OS_String::strcmp (type_id.in (), - "IDL:omg.org/CORBA/TRANSIENT:1.0") == 0 || + "IDL:omg.org/CORBA/TRANSIENT:1.0") == 0 || ACE_OS_String::strcmp (type_id.in (), "IDL:omg.org/CORBA/OBJ_ADAPTER:1.0") == 0 || ACE_OS_String::strcmp (type_id.in (), @@ -577,8 +539,7 @@ namespace TAO Invocation_Status const s = this->orb_core ()->service_raise_transient_failure ( this->details_.request_service_context ().service_info (), - this->resolver_.profile () - ); + this->resolver_.profile ()); if (s == TAO_INVOKE_RESTART) return s; @@ -646,11 +607,10 @@ namespace TAO Invocation_Status Synch_Oneway_Invocation::remote_oneway (ACE_Time_Value *max_wait_time) - ACE_THROW_SPEC ((CORBA::Exception)) { ACE_Countdown_Time countdown (max_wait_time); - const CORBA::Octet response_flags = this->details_.response_flags (); + CORBA::Octet const response_flags = this->details_.response_flags (); Invocation_Status s = TAO_INVOKE_FAILURE; @@ -670,15 +630,15 @@ namespace TAO if (s != TAO_INVOKE_SUCCESS) return s; + + try + { #endif /*TAO_HAS_INTERCEPTORS */ - TAO_Transport* transport = - this->resolver_.transport (); + TAO_Transport* const transport = this->resolver_.transport (); - TAO_OutputCDR &cdr = transport->out_stream (); + TAO_OutputCDR &cdr = transport->out_stream (); - try - { cdr.message_attributes (this->details_.request_id (), this->resolver_.stub (), TAO_Transport::TAO_ONEWAY_REQUEST, @@ -690,7 +650,7 @@ namespace TAO countdown.update (); - if (transport->is_connected()) + if (transport->is_connected ()) { // We have a connected transport so we can send the message s = this->send_message (cdr, @@ -709,13 +669,10 @@ namespace TAO } #if TAO_HAS_INTERCEPTORS == 1 - s = - this->receive_other_interception (); -#endif /*TAO_HAS_INTERCEPTORS */ + s = this->receive_other_interception (); } catch ( ::CORBA::Exception& ex) { -#if TAO_HAS_INTERCEPTORS == 1 PortableInterceptor::ReplyStatus const status = this->handle_any_exception (&ex); @@ -724,11 +681,23 @@ namespace TAO s = TAO_INVOKE_RESTART; else if (status == PortableInterceptor::SYSTEM_EXCEPTION || status == PortableInterceptor::USER_EXCEPTION) -#else - ACE_UNUSED_ARG (ex); -#endif /*TAO_HAS_INTERCEPTORS*/ throw; } + catch (...) + { + // Notify interceptors of non-CORBA exception, and propagate + // that exception to the caller. + + PortableInterceptor::ReplyStatus const st = + this->handle_all_exception (); + + if (st == PortableInterceptor::LOCATION_FORWARD || + st == PortableInterceptor::TRANSPORT_RETRY) + s = TAO_INVOKE_RESTART; + else + throw; + } +#endif /* TAO_HAS_INTERCEPTORS */ return s; } |