diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-23 08:01:39 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-23 08:01:39 +0000 |
commit | 208af467b689031b0453d0b729efa1425b5579f9 (patch) | |
tree | 989ccbcf5f2f605abdf01b052b9511402ef2f775 /TAO | |
parent | b9fd1705509e18c18bc154fb4aaa31374bc94c38 (diff) | |
download | ATCD-208af467b689031b0453d0b729efa1425b5579f9.tar.gz |
Mon Nov 23 01:20:27 1998 Nanbor Wang <nanbor@cs.wustl.edu>
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/tao/Connect.cpp | 9 | ||||
-rw-r--r-- | TAO/tao/GIOP.cpp | 29 | ||||
-rw-r--r-- | TAO/tao/GIOP.h | 27 | ||||
-rw-r--r-- | TAO/tao/IIOP_Object.cpp | 70 | ||||
-rw-r--r-- | TAO/tao/Invocation.cpp | 149 | ||||
-rw-r--r-- | TAO/tao/try_macros.h | 55 |
6 files changed, 203 insertions, 136 deletions
diff --git a/TAO/tao/Connect.cpp b/TAO/tao/Connect.cpp index 7db93a83dd2..d25c680b6f2 100644 --- a/TAO/tao/Connect.cpp +++ b/TAO/tao/Connect.cpp @@ -526,7 +526,7 @@ TAO_Server_Connection_Handler::handle_input (ACE_HANDLE) int result = 0; int error_encountered = 0; - CORBA::Boolean response_required; + CORBA::Boolean response_required = 0; TAO_SVC_HANDLER *this_ptr = this; CORBA::ULong request_id = 0; @@ -569,8 +569,6 @@ TAO_Server_Connection_Handler::handle_input (ACE_HANDLE) case TAO_GIOP::EndOfFile: // Got a EOF - errno = EPIPE; - response_required = error_encountered = 0; result = -1; break; @@ -587,7 +585,12 @@ TAO_Server_Connection_Handler::handle_input (ACE_HANDLE) TAO_TRY_ENV.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_NO)); // FALLTHROUGH + case TAO_GIOP::CommunicationError: case TAO_GIOP::MessageError: + // Here, MessageError can either mean condition for + // GIOP::MessageError happened or a GIOP message was + // not successfully received. Sending back of + // GIOP::MessageError is handled in TAO_GIOP::parse_header. error_encountered = 1; break; } diff --git a/TAO/tao/GIOP.cpp b/TAO/tao/GIOP.cpp index 863bc03d8da..c25e0e9b8f0 100644 --- a/TAO/tao/GIOP.cpp +++ b/TAO/tao/GIOP.cpp @@ -399,7 +399,7 @@ error_message [TAO_GIOP_HEADER_LEN] = }; void -TAO_GIOP::send_error (TAO_Client_Connection_Handler *&handler) +TAO_GIOP::send_error (TAO_SVC_HANDLER *&handler) { TAO_GIOP::dump_msg ("send", (const u_char *) error_message, @@ -481,7 +481,7 @@ TAO_GIOP::recv_request (TAO_SVC_HANDLER *&handler, header_len = 5; if (CDR::grow (&msg.start_, header_len) == -1) - return TAO_GIOP::MessageError; + return TAO_GIOP::CommunicationError; // This should probably be an exception. char *header = msg.start_.rd_ptr (); ssize_t len = TAO_GIOP::read_buffer (connection, @@ -519,7 +519,7 @@ TAO_GIOP::recv_request (TAO_SVC_HANDLER *&handler, /* NOTREACHED */ } - return TAO_GIOP::MessageError; + return TAO_GIOP::CommunicationError; } // NOTE: if message headers, or whome messages, get encrypted in @@ -533,7 +533,11 @@ TAO_GIOP::recv_request (TAO_SVC_HANDLER *&handler, retval, message_size, orb_core) == -1) - return TAO_GIOP::MessageError; + { + TAO_GIOP::send_error (handler); + return TAO_GIOP::EndOfFile; // We didn't really receive + // anything useful here. + } // Make sure we have the full length in memory, growing the buffer // if needed. @@ -544,7 +548,7 @@ TAO_GIOP::recv_request (TAO_SVC_HANDLER *&handler, assert (message_size <= UINT_MAX); if (CDR::grow (&msg.start_, header_len + message_size) == -1) - return TAO_GIOP::MessageError; + return TAO_GIOP::CommunicationError; // Growing the buffer may have reset the rd_ptr(), but we want to // leave it just after the GIOP header (that was parsed already); @@ -590,7 +594,7 @@ TAO_GIOP::recv_request (TAO_SVC_HANDLER *&handler, // clean up, and ... if (TAO_orbdebug) ACE_DEBUG ((LM_DEBUG, "couldn't read rest of message\n")); - return TAO_GIOP::MessageError; + return TAO_GIOP::CommunicationError; } TAO_GIOP::dump_msg ("recv", @@ -623,7 +627,7 @@ TAO_GIOP::parse_header_std (TAO_InputCDR &cdr, && header [5] <= TAO_GIOP_MessageHeader::MY_MINOR)) { ACE_DEBUG ((LM_DEBUG, "bad header, version\n")); - return TAO_GIOP::MessageError; + return -1; } // Get the message type out and adjust the buffer's records to record @@ -682,17 +686,6 @@ TAO_GIOP::parse_header (TAO_InputCDR &cdr, message_size); } - -void -TAO_GIOP::make_error (TAO_OutputCDR &msg, ...) -{ - ACE_UNUSED_ARG (msg); // just for now - - // This [static] method will be somewhat like send_error() except - // that it won't actaully do any sending of data...it'll just stuff - // things into the <msg> instance. -} - CORBA::Boolean TAO_GIOP_LocateRequestHeader::init (TAO_InputCDR &msg, CORBA::Environment &env) diff --git a/TAO/tao/GIOP.h b/TAO/tao/GIOP.h index b29c63c23c3..779b6547893 100644 --- a/TAO/tao/GIOP.h +++ b/TAO/tao/GIOP.h @@ -289,16 +289,17 @@ public: // = DESCRIPTION // All GIOP messages include a header and message type. Not // really a message type, but needed to bring that information - // back somehow - - EndOfFile = -1, // "discovered" by either - Request = 0, // sent by client - Reply = 1, // by server - CancelRequest = 2, // by client - LocateRequest = 3, // by client - LocateReply = 4, // by server - CloseConnection = 5, // by server - MessageError = 6 // by both + // back somehow. + + CommunicationError = -2, // Invalid request. + EndOfFile = -1, // "discovered" by either. + Request = 0, // sent by client. + Reply = 1, // by server. + CancelRequest = 2, // by client. + LocateRequest = 3, // by client. + LocateReply = 4, // by server. + CloseConnection = 5, // by server. + MessageError = 6 // by both. }; static void close_connection (TAO_Client_Connection_Handler *&handle, @@ -320,16 +321,12 @@ public: TAO_ORB_Core *orb_core); // Reads message, returns message type from header. - static void make_error (TAO_OutputCDR &msg, ...); - // Construct a message containing an error so that it can be sent as - // a response to a request. - static void dump_msg (const char *label, const u_char *ptr, size_t len); // Print out a message header. - static void send_error (TAO_Client_Connection_Handler *&handler); + static void send_error (TAO_SVC_HANDLER *&handler); // Send an error message back to a caller. static ssize_t read_buffer (TAO_SOCK_Stream &peer, diff --git a/TAO/tao/IIOP_Object.cpp b/TAO/tao/IIOP_Object.cpp index 28a6f709898..8ebdc5cd06f 100644 --- a/TAO/tao/IIOP_Object.cpp +++ b/TAO/tao/IIOP_Object.cpp @@ -455,14 +455,18 @@ IIOP_Object::do_static_call (CORBA::Environment &env, ACE_TIMEPROBE (TAO_IIOP_OBJECT_DO_STATIC_CALL_GRAB_ORB_CORE); + TAO_GIOP_ReplyStatusType status; + // Do a locate_request if necessary/wanted. if (this->use_locate_request_ && this->first_locate_request_) { TAO_GIOP_Locate_Request_Invocation call (this, orb_core); + // Simply let these exceptions propagate up + // (if any of them occurs.) call.start (env); - TAO_GIOP_ReplyStatusType status = call.invoke (env); + status = call.invoke (env); this->first_locate_request_ = 0; @@ -491,10 +495,13 @@ IIOP_Object::do_static_call (CORBA::Environment &env, for (;;) { // Start the call by constructing the request message header. - call.start (env); + TAO_TRY_SYS + { + call.start (env); - ACE_TIMEPROBE (TAO_IIOP_OBJECT_DO_STATIC_CALL_INVOCATION_START); - if (env.exception () != 0) + ACE_TIMEPROBE (TAO_IIOP_OBJECT_DO_STATIC_CALL_INVOCATION_START); + } + TAO_CATCH_SYS (CORBA_SystemException, ex) { ACE_MT (ACE_GUARD (ACE_Lock, guard, @@ -502,33 +509,33 @@ IIOP_Object::do_static_call (CORBA::Environment &env, // If this is the fwd_profile, then check to see if we // need to go back to the original profile and try that. - if (this->fwd_profile_ == 0) - return; - else + if (this->fwd_profile_ != 0) { delete this->fwd_profile_; this->fwd_profile_ = 0; - + // See if we need to try again. if (this->fwd_profile_success_ == 1) { this->fwd_profile_success_ = 0; env.clear (); - continue; + TAO_GOTO (roundtrip_continue_label); } - else - return; } + TAO_RETHROW_RETURN_VOID_SYS; } + TAO_ENDTRY; this->put_params (env, info, call, args); - if (env.exception () != 0) return; + TAO_CHECK_ENV_RETURN_VOID (env); ACE_TIMEPROBE (TAO_IIOP_OBJECT_DO_STATIC_CALL_PUT_PARAMS); - TAO_GIOP_ReplyStatusType status = - call.invoke (info->excepts, info->except_count, env); - if (status == TAO_GIOP_SYSTEM_EXCEPTION) + TAO_TRY_SYS + { + status = call.invoke (info->excepts, info->except_count, env); + } + TAO_CATCH_SYS (CORBA_SystemException, ex) { ACE_MT (ACE_GUARD (ACE_Lock, guard, @@ -536,9 +543,7 @@ IIOP_Object::do_static_call (CORBA::Environment &env, // If this is the fwd_profile, then check to see if we // need to go back to the original profile and try that. - if (this->fwd_profile_ == 0) - return; - else + if (this->fwd_profile_ != 0) { delete this->fwd_profile_; this->fwd_profile_ = 0; @@ -548,12 +553,12 @@ IIOP_Object::do_static_call (CORBA::Environment &env, { this->fwd_profile_success_ = 0; env.clear (); - continue; + TAO_GOTO (roundtrip_continue_label); } - else - return; } + TAO_RETHROW_RETURN_VOID_SYS; } + TAO_ENDTRY; if (status == TAO_GIOP_USER_EXCEPTION) return; @@ -638,6 +643,7 @@ IIOP_Object::do_static_call (CORBA::Environment &env, env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); return; } + TAO_LABEL (roundtrip_continue_label); } } else @@ -648,9 +654,12 @@ IIOP_Object::do_static_call (CORBA::Environment &env, ACE_TIMEPROBE (TAO_IIOP_OBJECT_DO_STATIC_CALL_INVOCATION_CTOR); // Start the call by constructing the request message header. - call.start (env); - ACE_TIMEPROBE (TAO_IIOP_OBJECT_DO_STATIC_CALL_INVOCATION_START); - if (env.exception () != 0) + TAO_TRY_SYS + { + call.start (env); + ACE_TIMEPROBE (TAO_IIOP_OBJECT_DO_STATIC_CALL_INVOCATION_START); + } + TAO_CATCH_SYS (CORBA_SystemException, ex) { ACE_MT (ACE_GUARD (ACE_Lock, guard, @@ -658,9 +667,7 @@ IIOP_Object::do_static_call (CORBA::Environment &env, // If this is the fwd_profile, then check to see if we // need to go back to the original profile and try that. - if (this->fwd_profile_ == 0) - return; - else + if (this->fwd_profile_ != 0) { // @@ DB: Memory leak? this->fwd_profile_ = 0; @@ -670,15 +677,15 @@ IIOP_Object::do_static_call (CORBA::Environment &env, { this->fwd_profile_success_ = 0; env.clear (); - continue; + TAO_GOTO (oneway_continue_label); } - else - return; } + TAO_RETHROW_RETURN_VOID_SYS; } + TAO_ENDTRY; this->put_params (env, info, call, args); - if (env.exception () != 0) return; + TAO_CHECK_ENV_RETURN_VOID (env); ACE_TIMEPROBE (TAO_IIOP_OBJECT_DO_STATIC_CALL_PUT_PARAMS); /* TAO_GIOP_ReplyStatusType status = */ call.invoke (env); @@ -693,6 +700,7 @@ IIOP_Object::do_static_call (CORBA::Environment &env, // a loop, as above. return; } + TAO_LABEL (oneway_continue_label); } } diff --git a/TAO/tao/Invocation.cpp b/TAO/tao/Invocation.cpp index 87ee57a6f6d..bb2c52ea990 100644 --- a/TAO/tao/Invocation.cpp +++ b/TAO/tao/Invocation.cpp @@ -444,16 +444,23 @@ TAO_GIOP_Invocation::location_forward (TAO_InputCDR &inp_stream, // This object pointer will be now extracted. CORBA::Object_ptr object_ptr = 0; + int status = 0; - if (inp_stream.decode (CORBA::_tc_Object, - &(object_ptr), - 0, - env) != CORBA::TypeCode::TRAVERSE_CONTINUE) + TAO_TRY_SYS { + status = inp_stream.decode (CORBA::_tc_Object, + &(object_ptr), + 0, + env); + } + TAO_CATCH_SYS (CORBA_SystemException, ex) + { + // Handle the exception for this level here and throw it out again. dexc (env, "invoke, location forward (decode)"); - TAO_GIOP::send_error (this->data_->handler ()); - return TAO_GIOP_SYSTEM_EXCEPTION; + this->data_->handler ()->handle_close (); + TAO_RETHROW_RETURN_SYS (TAO_GIOP_SYSTEM_EXCEPTION); } + TAO_ENDTRY; // The object pointer has to be changed to a IIOP_Object pointer // in order to extract the profile. @@ -463,7 +470,8 @@ TAO_GIOP_Invocation::location_forward (TAO_InputCDR &inp_stream, if (iiopobj == 0) { - TAO_GIOP::send_error (this->data_->handler ()); + this->data_->handler ()->handle_close (); + env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO)); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -569,14 +577,20 @@ TAO_GIOP_Twoway_Invocation::invoke (CORBA::ExceptionList &exceptions, ACE_DEBUG ((LM_DEBUG, "(%P|%t) illegal GIOP message (%s) in response to my Request!\n", TAO_GIOP::message_name (m))); - env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); // FALLTHROUGH ... + case TAO_GIOP::CommunicationError: case TAO_GIOP::MessageError: // Couldn't read it for some reason ... exception's set already, // so just tell the other end about the trouble (closing the // connection) and return. - TAO_GIOP::send_error (this->data_->handler ()); + + // @@ This should only refer to "getting GIOP MessageError" message only. + this->data_->handler ()->handle_close (); + // FALLTHROUGH + + case TAO_GIOP::EndOfFile: + env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -611,8 +625,8 @@ TAO_GIOP_Twoway_Invocation::invoke (CORBA::ExceptionList &exceptions, this->inp_stream_ >> reply_ctx; if (!this->inp_stream_.good_bit ()) { + this->data_->handler ()->handle_close (); env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_NO)); - TAO_GIOP::send_error (this->data_->handler ()); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -621,9 +635,9 @@ TAO_GIOP_Twoway_Invocation::invoke (CORBA::ExceptionList &exceptions, || !this->inp_stream_.read_ulong (reply_status) || reply_status > TAO_GIOP_LOCATION_FORWARD) { - TAO_GIOP::send_error (this->data_->handler ()); - env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); + this->data_->handler ()->handle_close (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) bad Response header\n")); + env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -663,7 +677,7 @@ TAO_GIOP_Twoway_Invocation::invoke (CORBA::ExceptionList &exceptions, { if (this->inp_stream_.read_string (buf) == 0) { - TAO_GIOP::send_error (this->data_->handler ()); + this->data_->handler ()->handle_close (); env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_YES)); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -702,7 +716,6 @@ TAO_GIOP_Twoway_Invocation::invoke (CORBA::ExceptionList &exceptions, "Trying to interpret as a user exception")); } } - // else // this else is commented out, see the coment above { // Find it in the operation description and then use that // to get the typecode. @@ -712,23 +725,25 @@ TAO_GIOP_Twoway_Invocation::invoke (CORBA::ExceptionList &exceptions, i < exceptions.count (); i++) { - CORBA::TypeCode_ptr tcp = - exceptions.item (i, env); - if (env.exception () != 0) - { - TAO_GIOP::send_error (this->data_->handler ()); - return TAO_GIOP_SYSTEM_EXCEPTION; - } + CORBA::TypeCode_ptr tcp; + int loop_continue = 0; + TAO_TRY_SYS + { + tcp = exceptions.item (i, env); - const char *xid = tcp->id (env); - if (env.exception () != 0) - { - TAO_GIOP::send_error (this->data_->handler ()); - return TAO_GIOP_SYSTEM_EXCEPTION; - } + const char *xid = tcp->id (env); - if (ACE_OS::strcmp (buf, xid) != 0) - continue; + if (ACE_OS::strcmp (buf, xid) != 0) + loop_continue = 1; + } + TAO_CATCH_SYS (CORBA_SystemException, ex) + { + this->data_->handler ()->handle_close (); + TAO_RETHROW_RETURN_SYS (TAO_GIOP_SYSTEM_EXCEPTION); + } + TAO_ENDTRY; + if (loop_continue) + continue; const ACE_Message_Block* cdr = this->inp_stream_.start (); @@ -843,11 +858,18 @@ TAO_GIOP_Twoway_Invocation::invoke (TAO_Exception_Data *excepts, env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); // FALLTHROUGH ... + case TAO_GIOP::CommunicationError: case TAO_GIOP::MessageError: // Couldn't read it for some reason ... exception's set already, // so just tell the other end about the trouble (closing the // connection) and return. - TAO_GIOP::send_error (this->data_->handler ()); + + // @@ This should only refer to "getting GIOP MessageError" message only. + this->data_->handler ()->handle_close (); + // FALLTHROUGH + + case TAO_GIOP::EndOfFile: + env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -882,7 +904,7 @@ TAO_GIOP_Twoway_Invocation::invoke (TAO_Exception_Data *excepts, this->inp_stream_ >> reply_ctx; if (!this->inp_stream_.good_bit ()) { - TAO_GIOP::send_error (this->data_->handler ()); + this->data_->handler ()->handle_close (); env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_NO)); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -892,9 +914,9 @@ TAO_GIOP_Twoway_Invocation::invoke (TAO_Exception_Data *excepts, || !this->inp_stream_.read_ulong (reply_status) || reply_status > TAO_GIOP_LOCATION_FORWARD) { - TAO_GIOP::send_error (this->data_->handler ()); - env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); + this->data_->handler ()->handle_close (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) bad Response header\n")); + env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -934,7 +956,7 @@ TAO_GIOP_Twoway_Invocation::invoke (TAO_Exception_Data *excepts, { if (this->inp_stream_.read_string (buf) == 0) { - TAO_GIOP::send_error (this->data_->handler ()); + this->data_->handler ()->handle_close (); env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_YES)); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -974,35 +996,35 @@ TAO_GIOP_Twoway_Invocation::invoke (TAO_Exception_Data *excepts, i < except_count; i++) { - tcp = excepts[i].tc; - const char *xid = tcp->id (env); - - if (env.exception () != 0) - { - dexc (env, "invoke (), get exception ID"); - TAO_GIOP::send_error (this->data_->handler ()); - return TAO_GIOP_SYSTEM_EXCEPTION; - } - - if (ACE_OS::strcmp (buf, (char *)xid) == 0) + int loop_continue = 0; + TAO_TRY_SYS { - // match - exception = excepts[i].alloc (); + tcp = excepts[i].tc; + const char *xid = tcp->id (env); - if (env.exception () != 0) + if (ACE_OS::strcmp (buf, (char *)xid) != 0) + loop_continue = 1; + else { - dexc (env, "invoke (), get exception size"); - TAO_GIOP::send_error (this->data_->handler ()); - return TAO_GIOP_SYSTEM_EXCEPTION; + // match + exception = excepts[i].alloc (); + + this->inp_stream_.decode (exception->_type (), + exception, 0, + env); } - this->inp_stream_.decode (exception->_type (), - exception, 0, - env); - if (env.exception () != 0) - return TAO_GIOP_SYSTEM_EXCEPTION; - env.exception (exception); - return TAO_GIOP_USER_EXCEPTION; } + TAO_CATCH_SYS (CORBA_SystemException, ex) + { + this->data_->handler ()->handle_close (); + TAO_RETHROW_RETURN_SYS (TAO_GIOP_SYSTEM_EXCEPTION); + } + TAO_ENDTRY; + if (loop_continue) + continue; + + env.exception (exception); + return TAO_GIOP_USER_EXCEPTION; } // end of loop CORBA::string_free (buf); } @@ -1073,7 +1095,7 @@ TAO_GIOP_Locate_Request_Invocation::invoke (CORBA::Environment &env) || request_id != this->my_request_id_ || !this->inp_stream_.read_ulong (locate_status)) { - TAO_GIOP::send_error (this->data_->handler ()); + this->data_->handler ()->handle_close (); env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) bad Response header\n")); @@ -1109,11 +1131,18 @@ TAO_GIOP_Locate_Request_Invocation::invoke (CORBA::Environment &env) env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); // FALLTHROUGH ... + case TAO_GIOP::CommunicationError: case TAO_GIOP::MessageError: // Couldn't read it for some reason ... exception's set already, // so just tell the other end about the trouble (closing the // connection) and return. - TAO_GIOP::send_error (this->data_->handler ()); + + // @@ This should only refer to "getting GIOP MessageError" message only. + this->data_->handler ()->handle_close (); + // FALLTHROUGH + + case TAO_GIOP::EndOfFile: + env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_MAYBE)); return TAO_GIOP_SYSTEM_EXCEPTION; } diff --git a/TAO/tao/try_macros.h b/TAO/tao/try_macros.h index f25a626350d..7d31821cf34 100644 --- a/TAO/tao/try_macros.h +++ b/TAO/tao/try_macros.h @@ -37,12 +37,17 @@ // The second "do" scope is for the TAO_CHECK_ENV continues. // These are all on one line so the keywords don't confuse compilers. #define TAO_TRY do { CORBA_Environment TAO_TRY_ENV; try { - +// TAO_*_SYS macros don't declare a new environment variable but use +// existing ones. +#define TAO_TRY_SYS do { try { #define TAO_TRY_EX(LABEL) do { CORBA_Environment TAO_TRY_ENV; try { #define TAO_CATCH(TYPE,VAR) } catch (TYPE & VAR) { ACE_UNUSED_ARG (VAR); +#define TAO_CATCH_SYS(TYPE,VAR) TAO_CATCH(TYPE,VAR) #define TAO_CATCHANY } catch (...) { +#define TAO_CATCHANY_SYS TAO_CATCHANY + #define TAO_ENDTRY }} while (0) // Use this macro if there's a return statement following TAO_ENDTRY @@ -51,13 +56,18 @@ // No need to do checking, exception handling does it for us. #define TAO_CHECK_ENV +#define TAO_CHECK_ENV_SYS #define TAO_CHECK_ENV_EX(LABEL) #define TAO_CHECK_ENV_RETURN(X, Y) +#define TAO_CHECK_ENV_SYS_RETURN(X, Y) #define TAO_THROW(EXCEPTION) throw EXCEPTION #define TAO_THROW_ENV(EXCEPTION, ENV) throw EXCEPTION #define TAO_RETHROW throw +#define TAO_GOTO(LABEL) goto LABEL +#define TAO_LABEL(LABEL) LABEL: + #if defined (ACE_WIN32) // MSVC++ gives a warning if there is no return after the throw @@ -71,15 +81,20 @@ return RETURN; } while (0) #define TAO_RETHROW_RETURN(RETURN) throw; \ return RETURN +#define TAO_RETHROW_RETURN_VOID_SYS throw; \ + return #else #define TAO_THROW_RETURN(EXCEPTION, RETURN) throw EXCEPTION #define TAO_THROW_ENV_RETURN(EXCEPTION, ENV, RETURN) throw EXCEPTION #define TAO_RETHROW_RETURN(RETURN) throw +#define TAO_RETUROW_RETURN_VOID_SYS throw #endif /* ACE_WIN32 */ +#define TAO_RETHROW_RETURN_SYS(RETURN) TAO_RETHROW_RETURN (RETURN) + // #define TAO_THROW_SPEC(X) ACE_THROW_SPEC(X) #define TAO_THROW_SPEC(X) // The IDL compiler is not generating throw specs, so putting them in @@ -116,6 +131,13 @@ TAO_TRY_LABEL: \ if (TAO_TRY_FLAG) \ do { +#define TAO_TRY_SYS \ +do { \ +int TAO_TRY_FLAG = 1; \ +TAO_TRY_LABEL: \ +if (TAO_TRY_FLAG) \ +do { + // This serves a similar purpose as the macro above, // The second "do" scope is for the TAO_CHECK_ENV continues. #define TAO_TRY_EX(LABEL) \ @@ -130,18 +152,24 @@ do { // Since all CATCH statements can end the TAO_TRY macro, they must all // start a new scope for the next potential TAO_CATCH. The TAO_ENDTRY // will finish them all. Cool, eh? -#define TAO_CATCH(TYPE,VAR) \ +#define TAO_CATCH_BASE(TYPE,VAR,ENV) \ } while (0); \ do \ -if (TAO_TRY_ENV.exception () != 0 && \ - TYPE::_narrow(TAO_TRY_ENV.exception ()) != 0) { \ - TYPE &VAR = *TYPE::_narrow (TAO_TRY_ENV.exception ()); \ +if (ENV.exception () != 0 && \ + TYPE::_narrow(ENV.exception ()) != 0) { \ + TYPE &VAR = *TYPE::_narrow (ENV.exception ()); \ ACE_UNUSED_ARG (VAR); -#define TAO_CATCHANY \ +#define TAO_CATCH(TYPE,VAR) TAO_CATCH_BASE(TYPE,VAR,TAO_TRY_ENV) +#define TAO_CATCH_SYS(TYPE,VAR) TAO_CATCH_BASE(TYPE,VAR,env) + +#define TAO_CATCHANY_BASE(ENV) \ } while (0); \ do { \ -if (TAO_TRY_ENV.exception () != 0) +if (ENV.exception () != 0) + +#define TAO_CATCHANY TAO_CATCHANY_BASE(TAO_TRY_ENV) +#define TAO_CATCHANY_SYS TAO_CATCHANY_BASE(env) // The first "while" closes the local scope. The second "while" // closes the TAO_TRY_ENV scope. @@ -155,15 +183,18 @@ if (TAO_TRY_ENV.exception () != 0) // If continue is called, control will skip to the next TAO_CATCHANY // statement. -#define TAO_CHECK_ENV \ +#define TAO_CHECK_ENV_BASE(ENV) \ {\ -if (TAO_TRY_ENV.exception () != 0) \ +if (ENV.exception () != 0) \ { \ TAO_TRY_FLAG = 0; \ goto TAO_TRY_LABEL; \ } \ } +#define TAO_CHECK_ENV TAO_CHECK_ENV_BASE(TAO_TRY_ENV) +#define TAO_CHECK_ENV_SYS TAO_CHECK_ENV_BASE(env) + // Same as above but for TAO_TRY_EX #define TAO_CHECK_ENV_EX(LABEL) \ do {\ @@ -201,10 +232,16 @@ do {\ _env.exception (TAO_TRY_ENV.exception ()); \ return +#define TAO_GOTO(LABEL) goto LABEL +#define TAO_LABEL(LABEL) LABEL: + #define TAO_RETHROW_RETURN(RETURN) \ _env.exception (TAO_TRY_ENV.exception ()); \ return RETURN +#define TAO_RETHROW_RETURN_SYS(RETURN) return RETURN +#define TAO_RETHROW_RETURN_VOID_SYS return + #define TAO_THROW_SPEC(X) #define TAO_RAISE(EXCEPTION) |