2 #include "ServerRequest_Interceptor2.h"
3 #include "orbsvcs/FT_CORBA_ORBC.h"
5 #include "tao/ORB_Constants.h"
6 #include "tao/AnyTypeCode/DynamicC.h"
7 #include "tao/AnyTypeCode/TypeCode.h"
9 #include "ace/Log_Msg.h"
10 #include "ace/OS_NS_string.h"
11 #include "ace/OS_NS_stdio.h"
12 #include "ace/OS_NS_unistd.h"
14 #include "ace/OS_NS_sys_time.h"
15 #include "tao/PI/PIForwardRequestC.h"
17 int invocation_count
= 0;
19 TAO249_ServerRequest_Interceptor2::TAO249_ServerRequest_Interceptor2 ()
25 TAO249_ServerRequest_Interceptor2::~TAO249_ServerRequest_Interceptor2 ()
30 TAO249_ServerRequest_Interceptor2::name ()
32 return CORBA::string_dup ("TAO_TAO249_ServerRequest_Interceptor2");
36 TAO249_ServerRequest_Interceptor2::destroy ()
41 TAO249_ServerRequest_Interceptor2::receive_request_service_contexts (
42 PortableInterceptor::ServerRequestInfo_ptr
48 TAO249_ServerRequest_Interceptor2::receive_request (
49 PortableInterceptor::ServerRequestInfo_ptr ri
52 CORBA::String_var op
= ri
->operation ();
54 if (ACE_OS::strcmp (op
.in (), "throw_location_forward"))
56 // bail if not the op we are interested in -
57 // avoid excess spurious error clutter when client calls ::shutdown
62 IOP::ServiceContext_var sc
=
63 ri
->get_request_service_context (IOP::FT_REQUEST
);
66 TAO_InputCDR
cdr (reinterpret_cast <const char*>
67 (sc
->context_data
.get_buffer ()
69 sc
->context_data
.length ());
71 CORBA::Boolean byte_order
;
73 if ((cdr
>> ACE_InputCDR::to_boolean (byte_order
)) == 0)
75 throw CORBA::BAD_PARAM (CORBA::OMGVMCID
| 28,
80 cdr
.reset_byte_order (static_cast <int>(byte_order
));
82 FT::FTRequestServiceContext ftrsc
;
84 if ((cdr
>> ftrsc
) == 0)
85 throw CORBA::BAD_PARAM (CORBA::OMGVMCID
| 28,
89 TimeBase::TimeT now
= get_now ();
91 if (now
> ftrsc
.expiration_time
)
93 // We have passed the exp time... there should be no more retries received after this point...
96 // The client has retried more than once after the expiration time. This is a regression
97 ACE_DEBUG ((LM_ERROR
, "Test Failed - REGRESSION !!! Client ORB is still retrying LOCATION_FORWARDs / TRANSIENTS after the expiration time on invocation # %d !!\n", invocation_count
+ 1));
98 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Expiration time : %Q\n"), ftrsc
.expiration_time
));
99 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Time now : %Q\n"), now
));
101 // Let the request 'succeed' rather than throwing a forward exception.
106 // A request has been recioved after the expiration time.
107 // This could legitimately happen - it is only definitely a problem if
108 // the client keeps on retrying after now. We set a flag so we can check for this.
110 ACE_DEBUG ((LM_DEBUG
, "The expiration time has now passed !! The next exception must NOT prompt reinvocation.\n"));
111 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Expiration time : %Q\n"), ftrsc
.expiration_time
));
112 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Time now : %Q\n"), now
));
116 if (invocation_count
== 0)
121 ACE_DEBUG ((LM_DEBUG
, "On invocation #%d throwing a ForwardRequest back to the client\n", invocation_count
));
123 // Throw a forward back to ourselves on the first try
124 // This means that we are testing the exception handling after a forward perm...
125 throw PortableInterceptor::ForwardRequest (server_iogr_
.in ());
132 ACE_DEBUG ((LM_DEBUG
, "On invocation #%d throwing a TRANSIENT back to the client\n", invocation_count
));
134 // Thaen throw a transient on all subsequent invocations
135 throw CORBA::TRANSIENT (0, CORBA::COMPLETED_NO
);
140 TAO249_ServerRequest_Interceptor2::get_now ()
143 const TimeBase::TimeT timeOffset
= ACE_UINT64_LITERAL (0x1B21DD213814000);
146 ACE_Time_Value time_value
= ACE_OS::gettimeofday ();
148 TimeBase::TimeT sec_part
= time_value
.sec ();
149 sec_part
= sec_part
* 10000000;
150 TimeBase::TimeT usec_part
= time_value
.usec ();
151 usec_part
= usec_part
* 10;
152 return (sec_part
+ usec_part
+ timeOffset
);
156 TAO249_ServerRequest_Interceptor2::send_reply (
157 PortableInterceptor::ServerRequestInfo_ptr
163 TAO249_ServerRequest_Interceptor2::send_exception (
164 PortableInterceptor::ServerRequestInfo_ptr
170 TAO249_ServerRequest_Interceptor2::send_other (
171 PortableInterceptor::ServerRequestInfo_ptr