Go to the documentation of this file.00001
00002
00003 #include "tao/Messaging/Asynch_Invocation.h"
00004 #include "tao/Messaging/Asynch_Reply_Dispatcher.h"
00005
00006 #include "tao/Profile_Transport_Resolver.h"
00007 #include "tao/Invocation_Utils.h"
00008 #include "tao/operation_details.h"
00009 #include "tao/Bind_Dispatcher_Guard.h"
00010 #include "tao/Transport.h"
00011 #include "tao/Muxed_TMS.h"
00012 #include "tao/GIOP_Message_Base.h"
00013 #include "tao/ORB_Constants.h"
00014
00015 #if TAO_HAS_INTERCEPTORS == 1
00016 # include "tao/PortableInterceptorC.h"
00017 #endif
00018
00019 ACE_RCSID (Messaging,
00020 Asynch_Invocation,
00021 "$Id: Asynch_Invocation.cpp 84457 2009-02-13 14:52:13Z msmit $")
00022
00023 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00024
00025 namespace TAO
00026 {
00027 Asynch_Remote_Invocation::Asynch_Remote_Invocation (
00028 CORBA::Object_ptr otarget,
00029 Profile_Transport_Resolver &resolver,
00030 TAO_Operation_Details &detail,
00031 TAO_Asynch_Reply_Dispatcher_Base *rd,
00032 bool response_expected)
00033 : Synch_Twoway_Invocation (otarget,
00034 resolver,
00035 detail,
00036 response_expected)
00037 , safe_rd_ (rd)
00038 {
00039 }
00040
00041 Invocation_Status
00042 Asynch_Remote_Invocation::remote_invocation (ACE_Time_Value *max_wait_time)
00043 {
00044 Invocation_Status s = TAO_INVOKE_FAILURE;
00045
00046 #if TAO_HAS_INTERCEPTORS == 1
00047 s = this->send_request_interception ();
00048
00049 if (s != TAO_INVOKE_SUCCESS)
00050 return s;
00051
00052
00053
00054
00055 try
00056 {
00057 #endif
00058 TAO_Transport* const transport = this->resolver_.transport ();
00059
00060 if (!transport)
00061 {
00062
00063
00064
00065 throw CORBA::TRANSIENT (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO);
00066 }
00067
00068 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon,
00069 transport->output_cdr_lock (), TAO_INVOKE_FAILURE);
00070
00071 TAO_OutputCDR & cdr =
00072 this->resolver_.transport ()->messaging_object ()->out_stream ();
00073
00074
00075
00076 cdr.message_attributes (this->details_.request_id (),
00077 this->resolver_.stub (),
00078 TAO_ONEWAY_REQUEST,
00079 max_wait_time);
00080
00081 this->write_header (cdr);
00082
00083 this->marshal_data (cdr);
00084
00085
00086
00087 TAO_Bind_Dispatcher_Guard dispatch_guard (
00088 this->details_.request_id (),
00089 this->safe_rd_.get (),
00090 transport->tms ());
00091
00092
00093
00094 this->safe_rd_.release ();
00095
00096 if (dispatch_guard.status () != 0)
00097 {
00098
00099
00100 throw ::CORBA::INTERNAL (TAO::VMCID, CORBA::COMPLETED_NO);
00101 }
00102
00103
00104
00105
00106
00107 dispatch_guard.status (TAO_Bind_Dispatcher_Guard::NO_UNBIND);
00108
00109
00110
00111
00112 s = this->send_message (cdr,
00113 TAO_ONEWAY_REQUEST,
00114 max_wait_time);
00115
00116 ace_mon.release();
00117
00118 #if TAO_HAS_INTERCEPTORS == 1
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 Invocation_Status const tmp = this->receive_other_interception ();
00132
00133
00134 if (s == TAO_INVOKE_SUCCESS && tmp != TAO_INVOKE_SUCCESS)
00135 s = tmp;
00136 #endif
00137
00138
00139
00140
00141 if (s != TAO_INVOKE_SUCCESS)
00142 return s;
00143
00144
00145
00146 if (transport->idle_after_send ())
00147 (void) this->resolver_.transport_released ();
00148
00149 #if TAO_HAS_INTERCEPTORS == 1
00150 }
00151 catch ( ::CORBA::Exception& ex)
00152 {
00153
00154 PortableInterceptor::ReplyStatus const status =
00155 this->handle_any_exception (&ex);
00156
00157 if (status == PortableInterceptor::LOCATION_FORWARD ||
00158 status == PortableInterceptor::TRANSPORT_RETRY)
00159 s = TAO_INVOKE_RESTART;
00160 else if (status == PortableInterceptor::SYSTEM_EXCEPTION
00161 || status == PortableInterceptor::USER_EXCEPTION)
00162 throw;
00163 }
00164 catch (...)
00165 {
00166
00167
00168
00169 PortableInterceptor::ReplyStatus const st =
00170 this->handle_all_exception ();
00171
00172 if (st == PortableInterceptor::LOCATION_FORWARD ||
00173 st == PortableInterceptor::TRANSPORT_RETRY)
00174 s = TAO_INVOKE_RESTART;
00175 else
00176 throw;
00177 }
00178 #endif
00179
00180 return s;
00181 }
00182 }
00183
00184 TAO_END_VERSIONED_NAMESPACE_DECL