Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_GIOP_Synch_Invocation Class Reference

TAO_GIOP_Synch_Invocation. More...

#include <Invocation.h>

Inheritance diagram for TAO_GIOP_Synch_Invocation:

Inheritance graph
[legend]
Collaboration diagram for TAO_GIOP_Synch_Invocation:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_GIOP_Synch_Invocation (void)
 Default constructor. This should never get called, it is here only to appease older versions of g++. More...

 TAO_GIOP_Synch_Invocation (TAO_Stub *stub, const char *operation, CORBA::ULong opname_len, CORBA::Boolean argument_flag, TAO_ORB_Core *orb_core, int byte_order=TAO_ENCAP_BYTE_ORDER)
 Constructor. More...

virtual ~TAO_GIOP_Synch_Invocation (void)
 Destructor. More...

TAO_InputCDRinp_stream (void)
 Return the underlying input stream. Called by the stub to demarshal the results of the upcall into whatever return arguments there may be. More...


Protected Methods

int invoke_i (CORBA::Boolean is_locate_request ACE_ENV_ARG_DECL) throw (CORBA::SystemException)
 Implementation of the invoke() methods, handles the basic send/reply code and the system exceptions. More...


Protected Attributes

TAO_Synch_Reply_Dispatcher rd_
 Reply dispatcher for the current synchronous invocation. More...


Private Methods

int validate_error (TAO_Bind_Dispatcher_Guard &ACE_ENV_ARG_DECL) throw (CORBA::SystemException)
 Helper method for validating the error. Returns 0 to if processing can be continued or returns -1 to indicate a real error with the invocation. Useful mostly for validating timeouts that we got back from LF. More...


Detailed Description

TAO_GIOP_Synch_Invocation.

Base class for TAO_GIOP_Twoway_Invocation and TAO_GIOP_Oneway_Invocation.

Definition at line 338 of file Invocation.h.


Constructor & Destructor Documentation

TAO_GIOP_Synch_Invocation::TAO_GIOP_Synch_Invocation void   
 

Default constructor. This should never get called, it is here only to appease older versions of g++.

Definition at line 586 of file Invocation.cpp.

00587   : rd_ (0,
00588          this->op_details_.reply_service_info ())
00589 {
00590 }

ACE_INLINE TAO_GIOP_Synch_Invocation::TAO_GIOP_Synch_Invocation TAO_Stub   stub,
const char *    operation,
CORBA::ULong    opname_len,
CORBA::Boolean    argument_flag,
TAO_ORB_Core   orb_core,
int    byte_order = TAO_ENCAP_BYTE_ORDER
 

Constructor.

Definition at line 139 of file Invocation.i.

00147   : TAO_GIOP_Invocation (stub,
00148                          operation,
00149                          opname_len,
00150                          argument_flag,
00151                          orb_core,
00152        byte_order),
00153     rd_ (orb_core,
00154          this->op_details_.reply_service_info   ())
00155 {
00156 }

TAO_GIOP_Synch_Invocation::~TAO_GIOP_Synch_Invocation void    [virtual]
 

Destructor.

Definition at line 592 of file Invocation.cpp.

References TAO_Transport::idle_after_reply, and TAO_GIOP_Invocation::transport_.

00593 {
00594   if (this->transport_ != 0)
00595     {
00596       this->transport_->idle_after_reply ();
00597     }
00598 }


Member Function Documentation

ACE_INLINE TAO_InputCDR & TAO_GIOP_Synch_Invocation::inp_stream void   
 

Return the underlying input stream. Called by the stub to demarshal the results of the upcall into whatever return arguments there may be.

Definition at line 159 of file Invocation.i.

References TAO_Transport::assign_translators, rd_, TAO_Synch_Reply_Dispatcher::reply_cdr, and TAO_GIOP_Invocation::transport_.

Referenced by TAO_Remote_Object_Proxy_Impl::_get_component, TAO_Remote_Object_Proxy_Impl::_is_a, TAO_Remote_Object_Proxy_Impl::_non_existent, CORBA::_TAO_Policy_Remote_Proxy_Impl::copy, CORBA::_TAO_DomainManager_Remote_Proxy_Impl::get_domain_policy, TAO_CORBANAME_Parser::parse_string_dynamic_request_helper, and CORBA::_TAO_Policy_Remote_Proxy_Impl::policy_type.

00160 {
00161   this->transport_->assign_translators(&this->rd_.reply_cdr(),0);
00162   return this->rd_.reply_cdr ();
00163 }

int TAO_GIOP_Synch_Invocation::invoke_i CORBA::Boolean is_locate_request    ACE_ENV_ARG_DECL throw (CORBA::SystemException) [protected]
 

Implementation of the invoke() methods, handles the basic send/reply code and the system exceptions.

Definition at line 601 of file Invocation.cpp.

References ACE_CHECK_RETURN, ACE_DEBUG, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_RAISE, ACE_NEW_RETURN, ACE_THROW_RETURN, TAO_Exceptions::create_system_exception, TAO_GIOP_Invocation::invoke, LM_DEBUG, TAO_Bind_Dispatcher_Guard::status, TAO_DEFAULT_MINOR_CODE, TAO_INVOKE_EXCEPTION, TAO_INVOKE_OK, TAO_INVOKE_RESTART, TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD, TAO_PLUGGABLE_MESSAGE_NEEDS_ADDRESSING_MODE, TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION, TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION, TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION, TAO_Transport::TAO_TWOWAY_REQUEST, and TAO_Bind_Dispatcher_Guard::unbind_dispatcher.

00604 {
00605   // Register a reply dispatcher for this invocation. Use the
00606   // preallocated reply dispatcher.
00607   TAO_Bind_Dispatcher_Guard dispatch_guard (
00608     this->op_details_.request_id (),
00609     &this->rd_,
00610     this->transport_->tms ());
00611 
00612   if (dispatch_guard.status () != 0)
00613     {
00614       // @@ What is the right way to handle this error?
00615       this->close_connection ();
00616 
00617       ACE_THROW_RETURN (CORBA::INTERNAL (TAO_DEFAULT_MINOR_CODE,
00618                                          CORBA::COMPLETED_NO),
00619                         TAO_INVOKE_EXCEPTION);
00620     }
00621 
00622   // Just send the request, without trying to wait for the reply.
00623   int retval = TAO_GIOP_Invocation::invoke (TAO_Transport::TAO_TWOWAY_REQUEST
00624                                             ACE_ENV_ARG_PARAMETER);
00625   ACE_CHECK_RETURN (retval);
00626 
00627   if (retval != TAO_INVOKE_OK)
00628     {
00629       return retval;
00630     }
00631 
00632   // This blocks until the response is read.  In the current version,
00633   // there is only one client thread that ever uses this connection,
00634   // so most response messages are illegal.
00635   //
00636   // @@ In all MT environments, there's a cancellation point lurking
00637   // here; need to investigate.  Client threads would frequently be
00638   // canceled sometime during recv_request ... the correct action to
00639   // take on being canceled is to issue a CancelRequest message to the
00640   // server and then imediately let other client-side cancellation
00641   // handlers do their jobs.
00642   //
00643   // In C++, that basically means to unwind the stack using almost
00644   // normal procedures: all destructors should fire, and some "catch"
00645   // blocks should probably be able to handle things like releasing
00646   // pointers. (Without unwinding the C++ stack, resources that must
00647   // be freed by thread cancellation won't be freed, and the process
00648   // won't continue to function correctly.)  The tricky part is that
00649   // according to POSIX, all C stack frames must also have their
00650   // (explicitly coded) handlers called.  We assume a POSIX.1c/C/C++
00651   // environment.
00652 
00653   // Get the reply status.
00654 
00655   // Wait for the reply.
00656 
00657   if (TAO_debug_level > 0 && this->max_wait_time_ != 0)
00658     {
00659       CORBA::ULong msecs = this->max_wait_time_->msec ();
00660 
00661       ACE_DEBUG ((LM_DEBUG,
00662                   "TAO (%P|%t) - Synch_Invocation::invoke_i, "
00663                   "timeout on recv is <%u>\n",
00664                   msecs));
00665     }
00666 
00667   int reply_error =
00668     this->transport_->wait_strategy ()->wait (this->max_wait_time_,
00669                                               this->rd_);
00670 
00671 
00672   if (TAO_debug_level > 0 && this->max_wait_time_ != 0)
00673     {
00674       CORBA::ULong msecs = this->max_wait_time_->msec ();
00675 
00676       ACE_DEBUG ((LM_DEBUG,
00677                   "TAO (%P|%t) Synch_Invocation::invoke_i, "
00678                   "timeout after recv is <%u> status <%d>\n",
00679                   msecs,
00680                   reply_error));
00681     }
00682 
00683   // Check the reply error.
00684   if (reply_error == -1)
00685     {
00686       // Check whether the error that occured is really true or not.
00687       reply_error =
00688         this->validate_error (dispatch_guard
00689                               ACE_ENV_ARG_PARAMETER);
00690       ACE_CHECK_RETURN (reply_error);
00691     }
00692 
00693   // If this is still an error that needs other handlers to be used ,
00694   // call the ORB Core which can take care of the rest..
00695   if (reply_error == -1)
00696     {
00697       // Just unbind the dispatcher before we take any action.
00698       (void) dispatch_guard.unbind_dispatcher ();
00699       return
00700         this->orb_core_->service_raise_comm_failure (this,
00701                                                      this->profile_
00702                                                      ACE_ENV_ARG_PARAMETER);
00703     }
00704   // @@ Alex: the old version of this had some error handling code,
00705   //    like:  this->profile_->reset_hint ()
00706   //    Can you make sure we don't forget to do that on exceptions
00707   //    and/or errors.
00708   //    BTW, think about native exceptions where if the exception is
00709   //    raised in the wait() method you won't get a chance
00710   //    to do that kind of error handling.  Do you really need
00711   //    exceptions in the transport objects?
00712 
00713   CORBA::ULong reply_status = this->rd_.reply_status ();
00714 
00715   if (is_locate_request)
00716     {
00717       // A locate request checks a different set of enum return values,
00718       // so we return to the TAO_GIOP_Locate_Request_Invocation caller
00719       // to do that.
00720       return reply_status;
00721     }
00722 
00723   // Set the reply status to zero before we get out. This is no longer required
00724   switch (reply_status)
00725     {
00726     case TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION:
00727       // Return so that the STUB can demarshal the reply.
00728       return TAO_INVOKE_OK;
00729 
00730     case TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION:
00731         // Return so the exception can be handled.
00732         return TAO_INVOKE_EXCEPTION;
00733 
00734     case TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION:
00735       {
00736         // @@ Add the location macros for this exceptions...
00737 
00738         CORBA::String_var type_id;
00739 
00740         if ((this->inp_stream () >> type_id.inout ()) == 0)
00741           {
00742             // Could not demarshal the exception id, raise an local
00743             // CORBA::MARSHAL
00744             ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
00745                                               CORBA::COMPLETED_MAYBE),
00746                               TAO_INVOKE_OK);
00747           }
00748 
00749         CORBA::ULong minor = 0;
00750         CORBA::ULong completion = 0;
00751 
00752         if ((this->inp_stream () >> minor) == 0
00753             || (this->inp_stream () >> completion) == 0)
00754           {
00755             ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
00756                                               CORBA::COMPLETED_MAYBE),
00757                               TAO_INVOKE_OK);
00758           }
00759 
00760         CORBA::SystemException *ex =
00761           TAO_Exceptions::create_system_exception (type_id.in ()
00762                                                    ACE_ENV_ARG_PARAMETER);
00763         ACE_CHECK_RETURN (TAO_INVOKE_OK);
00764 
00765         if (ex == 0)
00766           {
00767             // @@ We should raise a CORBA::NO_MEMORY, but we ran out
00768             //    of memory already. We need a pre-allocated, TSS,
00769             //    CORBA::NO_MEMORY instance
00770             ACE_NEW_RETURN (ex,
00771                             CORBA::UNKNOWN,
00772                             TAO_INVOKE_EXCEPTION);
00773           }
00774 
00775         ex->minor (minor);
00776         ex->completed (CORBA::CompletionStatus (completion));
00777 
00778 #if defined (TAO_HAS_EXCEPTIONS)
00779         // Without this, the call to create_system_exception() above
00780         // causes a memory leak. On platforms without native exceptions,
00781         // the CORBA_Environment class manages the memory.
00782         auto_ptr<CORBA::SystemException> safety (ex);
00783 #endif
00784 
00785         // Raise the exception.
00786         ACE_ENV_RAISE (ex);
00787 
00788         return TAO_INVOKE_OK;
00789       }
00790       // NOTREACHED.
00791 
00792     case TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD:
00793       // Handle the forwarding and return so the stub restarts the
00794       // request!
00795       return this->location_forward (this->inp_stream ()
00796                                      ACE_ENV_ARG_PARAMETER);
00797     case TAO_PLUGGABLE_MESSAGE_NEEDS_ADDRESSING_MODE:
00798       {
00799         // We have received an exception with a request to change the
00800         // addressing mode. First let us read the mode that the
00801         // server/agent asks for.
00802         CORBA::Short addr_mode = 0;
00803         if (this->inp_stream ().read_short (addr_mode) == 0)
00804           {
00805             // Could not demarshal the addressing disposition, raise an local
00806             // CORBA::MARSHAL
00807             ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
00808                                               CORBA::COMPLETED_MAYBE),
00809                               TAO_INVOKE_OK);
00810           }
00811 
00812         // Now set this addressing mode in the profile, so that
00813         // the next invocation need not go through this.
00814         this->profile_->addressing_mode (addr_mode
00815                                          ACE_ENV_ARG_PARAMETER);
00816 
00817         // Now restart the invocation
00818         return TAO_INVOKE_RESTART;
00819       }
00820 
00821     }
00822 
00823   return TAO_INVOKE_OK;
00824 }

int TAO_GIOP_Synch_Invocation::validate_error TAO_Bind_Dispatcher_Guard   ACE_ENV_ARG_DECL throw (CORBA::SystemException) [private]
 

Helper method for validating the error. Returns 0 to if processing can be continued or returns -1 to indicate a real error with the invocation. Useful mostly for validating timeouts that we got back from LF.


Member Data Documentation

TAO_Synch_Reply_Dispatcher TAO_GIOP_Synch_Invocation::rd_ [protected]
 

Reply dispatcher for the current synchronous invocation.

Definition at line 371 of file Invocation.h.

Referenced by inp_stream, and TAO_GIOP_Twoway_Invocation::reset_states.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:17:39 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002