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 TAO249_ServerRequest_Interceptor2::TAO249_ServerRequest_Interceptor2 ()
23 TAO249_ServerRequest_Interceptor2::~TAO249_ServerRequest_Interceptor2 ()
28 TAO249_ServerRequest_Interceptor2::name ()
30 return CORBA::string_dup ("TAO_TAO249_ServerRequest_Interceptor2");
34 TAO249_ServerRequest_Interceptor2::destroy ()
39 TAO249_ServerRequest_Interceptor2::receive_request_service_contexts (
40 PortableInterceptor::ServerRequestInfo_ptr
)
45 TAO249_ServerRequest_Interceptor2::receive_request (
46 PortableInterceptor::ServerRequestInfo_ptr ri
)
48 CORBA::String_var op
= ri
->operation ();
50 if (ACE_OS::strcmp (op
.in (), "throw_location_forward"))
52 // bail if not the op we are interested in -
53 // avoid excess spurious error clutter when client calls ::shutdown
58 IOP::ServiceContext_var sc
=
59 ri
->get_request_service_context (IOP::FT_REQUEST
);
61 TAO_InputCDR
cdr (reinterpret_cast <const char*>
62 (sc
->context_data
.get_buffer ()
64 sc
->context_data
.length ());
66 CORBA::Boolean byte_order
;
68 if ((cdr
>> ACE_InputCDR::to_boolean (byte_order
)) == 0)
70 throw CORBA::BAD_PARAM (CORBA::OMGVMCID
| 28, CORBA::COMPLETED_NO
);
73 cdr
.reset_byte_order (static_cast <int>(byte_order
));
75 FT::FTRequestServiceContext ftrsc
;
77 if ((cdr
>> ftrsc
) == 0)
78 throw CORBA::BAD_PARAM (CORBA::OMGVMCID
| 28, CORBA::COMPLETED_NO
);
80 TimeBase::TimeT now
= get_now ();
82 if (now
> ftrsc
.expiration_time
)
84 // We have passed the exp time... there should be no more retries received after this point...
87 // The client has retried after the expiration time. This is a regression
88 ACE_DEBUG ((LM_ERROR
, "Test Failed - REGRESSION !!! Client ORB is still retrying LOCATION_FORWARDs after the expiration time!!\n"));
89 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Expiration time : %Q\n"), ftrsc
.expiration_time
));
90 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Time now : %Q\n"), now
));
92 // Let the request 'succeed' rather than throwing a forward exception.
97 // A request has been recioved after the expiration time.
98 // This could legitimately happen - it is only definitely a problem if
99 // the client keeps on retrying after now. We set a flag so we can check for this.
101 ACE_DEBUG ((LM_DEBUG
, "The expiration time has now passed !!\n"));
102 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Expiration time : %Q\n"), ftrsc
.expiration_time
));
103 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("Time now : %Q\n"), now
));
107 // Let's forward the client back to us again. I would like to be able to make this a PERM
108 // but there's no such animal in the PortableInterceptor module. Plus as we (currently) transform
109 // and marshal *all* forward requests as vanilla LOCATION_FORWARD it doesn't really matter.
110 throw PortableInterceptor::ForwardRequest (server_iogr_
.in ());
114 TAO249_ServerRequest_Interceptor2::get_now ()
117 const TimeBase::TimeT timeOffset
= ACE_UINT64_LITERAL (0x1B21DD213814000);
120 ACE_Time_Value time_value
= ACE_OS::gettimeofday ();
122 TimeBase::TimeT sec_part
= time_value
.sec ();
123 sec_part
= sec_part
* 10000000;
124 TimeBase::TimeT usec_part
= time_value
.usec ();
125 usec_part
= usec_part
* 10;
126 return (sec_part
+ usec_part
+ timeOffset
);
130 TAO249_ServerRequest_Interceptor2::send_reply (
131 PortableInterceptor::ServerRequestInfo_ptr
)
136 TAO249_ServerRequest_Interceptor2::send_exception (
137 PortableInterceptor::ServerRequestInfo_ptr
)
142 TAO249_ServerRequest_Interceptor2::send_other (
143 PortableInterceptor::ServerRequestInfo_ptr
)