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 (void)
25 TAO249_ServerRequest_Interceptor2::~TAO249_ServerRequest_Interceptor2 (void)
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
67 TAO_InputCDR
cdr (reinterpret_cast <const char*>
68 (sc
->context_data
.get_buffer ()
70 sc
->context_data
.length ());
72 CORBA::Boolean byte_order
;
74 if ((cdr
>> ACE_InputCDR::to_boolean (byte_order
)) == 0)
76 throw CORBA::BAD_PARAM (CORBA::OMGVMCID
| 28,
81 cdr
.reset_byte_order (static_cast <int>(byte_order
));
83 FT::FTRequestServiceContext ftrsc
;
85 if ((cdr
>> ftrsc
) == 0)
86 throw CORBA::BAD_PARAM (CORBA::OMGVMCID
| 28,
90 TimeBase::TimeT now
= get_now ();
92 if (now
> ftrsc
.expiration_time
)
94 // We have passed the exp time... there should be no more retries received after this point...
97 // The client has retried more than once after the expiration time. This is a regression
98 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));
99 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Expiration time : %Q\n"), ftrsc
.expiration_time
));
100 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Time now : %Q\n"), now
));
102 // Let the request 'succeed' rather than throwing a forward exception.
107 // A request has been recioved after the expiration time.
108 // This could legitimately happen - it is only definitely a problem if
109 // the client keeps on retrying after now. We set a flag so we can check for this.
111 ACE_DEBUG ((LM_DEBUG
, "The expiration time has now passed !! The next exception must NOT prompt reinvocation.\n"));
112 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Expiration time : %Q\n"), ftrsc
.expiration_time
));
113 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Time now : %Q\n"), now
));
117 if (invocation_count
== 0)
122 ACE_DEBUG ((LM_DEBUG
, "On invocation #%d throwing a ForwardRequest back to the client\n", invocation_count
));
124 // Throw a forward back to ourselves on the first try
125 // This means that we are testing the exception handling after a forward perm...
126 throw PortableInterceptor::ForwardRequest (server_iogr_
.in ());
133 ACE_DEBUG ((LM_DEBUG
, "On invocation #%d throwing a TRANSIENT back to the client\n", invocation_count
));
135 // Thaen throw a transient on all subsequent invocations
136 throw CORBA::TRANSIENT (0, CORBA::COMPLETED_NO
);
141 TAO249_ServerRequest_Interceptor2::get_now (void)
144 const TimeBase::TimeT timeOffset
= ACE_UINT64_LITERAL (0x1B21DD213814000);
147 ACE_Time_Value time_value
= ACE_OS::gettimeofday ();
149 TimeBase::TimeT sec_part
= time_value
.sec ();
150 sec_part
= sec_part
* 10000000;
151 TimeBase::TimeT usec_part
= time_value
.usec ();
152 usec_part
= usec_part
* 10;
153 return (sec_part
+ usec_part
+ timeOffset
);
157 TAO249_ServerRequest_Interceptor2::send_reply (
158 PortableInterceptor::ServerRequestInfo_ptr
164 TAO249_ServerRequest_Interceptor2::send_exception (
165 PortableInterceptor::ServerRequestInfo_ptr
171 TAO249_ServerRequest_Interceptor2::send_other (
172 PortableInterceptor::ServerRequestInfo_ptr