1 #include "ace/Get_Opt.h"
3 #include "tao/ORB_Core.h"
5 #include "tao/RTPortableServer/RTPortableServer.h"
6 #include "../check_supported_priorities.cpp"
7 #include "../common_args.cpp"
13 test_i (CORBA::ORB_ptr orb
,
14 PortableServer::POA_ptr poa
);
18 //FUZZ: disable check_for_lack_ACE_OS
20 //FUZZ: enable check_for_lack_ACE_OS
22 PortableServer::POA_ptr
_default_POA ();
26 PortableServer::POA_var poa_
;
29 test_i::test_i (CORBA::ORB_ptr orb
,
30 PortableServer::POA_ptr poa
)
31 : orb_ (CORBA::ORB::_duplicate (orb
)),
32 poa_ (PortableServer::POA::_duplicate (poa
))
47 "test_i::shutdown\n"));
49 this->orb_
->shutdown (false);
52 PortableServer::POA_ptr
53 test_i::_default_POA ()
55 return PortableServer::POA::_duplicate (this->poa_
.in ());
58 static CORBA::ULong stacksize
= 0;
59 static CORBA::ULong static_threads
= 2;
60 static CORBA::ULong dynamic_threads
= 0;
61 static CORBA::Boolean allow_request_buffering
= 0;
62 static CORBA::ULong max_buffered_requests
= 0;
63 static CORBA::ULong max_request_buffer_size
= 0;
64 static CORBA::Boolean allow_borrowing
= 0;
66 static const ACE_TCHAR
*ior
= ACE_TEXT("ior");
69 static const ACE_TCHAR
*bands_file
= ACE_TEXT ("bands");
70 static const ACE_TCHAR
*lanes_file
= ACE_TEXT ("lanes");
73 parse_args (int argc
, ACE_TCHAR
**argv
)
75 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:b:d:l:"));
78 while ((c
= get_opts ()) != -1)
82 ior
= get_opts
.opt_arg ();
86 bands_file
= get_opts
.opt_arg ();
90 debug
= ACE_OS::atoi (get_opts
.opt_arg ());
94 lanes_file
= get_opts
.opt_arg ();
99 ACE_ERROR_RETURN ((LM_ERROR
,
114 write_iors_to_file (CORBA::Object_ptr object
,
116 const ACE_TCHAR
*filename
)
119 ACE_OS::fopen (filename
, "w");
120 ACE_ASSERT (file
!= 0);
122 CORBA::String_var ior
=
123 orb
->object_to_string (object
);
127 ACE_OS::fprintf (file
,
131 ACE_ASSERT (result
== ACE_OS::strlen (ior
.in ()));
132 ACE_UNUSED_ARG (result
);
134 ACE_OS::fclose (file
);
137 class Task
: public ACE_Task_Base
140 Task (ACE_Thread_Manager
&thread_manager
,
148 Task::Task (ACE_Thread_Manager
&thread_manager
,
150 : ACE_Task_Base (&thread_manager
),
151 orb_ (CORBA::ORB::_duplicate (orb
))
160 CORBA::Object_var object
=
161 this->orb_
->resolve_initial_references ("RTORB");
163 RTCORBA::RTORB_var rt_orb
=
164 RTCORBA::RTORB::_narrow (object
.in ());
167 this->orb_
->resolve_initial_references ("RootPOA");
169 PortableServer::POA_var root_poa
=
170 PortableServer::POA::_narrow (object
.in ());
172 PortableServer::POAManager_var poa_manager
=
173 root_poa
->the_POAManager ();
175 CORBA::PolicyList policies
;
178 get_priority_bands ("server",
187 get_priority_lanes ("server",
193 allow_request_buffering
,
194 max_buffered_requests
,
195 max_request_buffer_size
,
202 CORBA::Policy_var priority_model_policy
=
203 rt_orb
->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED
,
206 // Implicit_activation policy.
207 CORBA::Policy_var implicit_activation_policy
=
208 root_poa
->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION
);
210 policies
.length (policies
.length () + 1);
211 policies
[policies
.length () - 1] =
212 priority_model_policy
;
214 policies
.length (policies
.length () + 1);
215 policies
[policies
.length () - 1] =
216 implicit_activation_policy
;
218 PortableServer::POA_var poa
=
219 root_poa
->create_POA ("child",
224 ACE_NEW_THROW_EX (servant
,
225 test_i (this->orb_
.in (),
227 CORBA::NO_MEMORY ());
229 PortableServer::ServantBase_var
safe_servant (servant
);
231 PortableServer::ObjectId_var id
=
232 poa
->activate_object (servant
);
234 CORBA::Object_var object_act
= poa
->id_to_reference (id
.in ());
237 test::_narrow (object_act
.in ());
239 write_iors_to_file (test
.in (),
243 poa_manager
->activate ();
247 this->orb_
->destroy ();
249 catch (const CORBA::Exception
& ex
)
251 ex
._tao_print_exception ("Exception caught");
259 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
264 CORBA::ORB_init (argc
, argv
);
267 parse_args (argc
, argv
);
271 // Make sure we can support multiple priorities that are required
273 if (!check_supported_priorities (orb
.in ()))
276 // Thread Manager for managing task.
277 ACE_Thread_Manager thread_manager
;
280 Task
task (thread_manager
,
283 // Task activation flags.
287 orb
->orb_core ()->orb_params ()->thread_creation_flags ();
291 task
.activate (flags
);
296 ACE_ERROR_RETURN ((LM_ERROR
,
297 "Cannot create thread with scheduling policy %C\n"
298 "because the user does not have the appropriate privileges, terminating program....\n"
299 "Check svc.conf options and/or run as root\n",
300 sched_policy_name (orb
->orb_core ()->orb_params ()->ace_sched_policy ())),
308 // Wait for task to exit.
310 thread_manager
.wait ();
311 ACE_ASSERT (result
!= -1);
313 catch (const CORBA::Exception
& ex
)
315 ex
._tao_print_exception ("Exception caught");