2 #include "ace/Get_Opt.h"
3 #include "ace/Sched_Params.h"
4 #include "ace/OS_NS_stdio.h"
5 #include "ace/OS_NS_errno.h"
8 static const ACE_TCHAR
*ior_output_file
= ACE_TEXT("test.ior");
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
16 while ((c
= get_opts ()) != -1)
20 ior_output_file
= get_opts
.opt_arg ();
25 ACE_ERROR_RETURN ((LM_ERROR
,
33 // Indicates successful parsing of the command line
40 int policy
= ACE_SCHED_FIFO
;
42 (ACE_Sched_Params::priority_min (policy
)
43 + ACE_Sched_Params::priority_max (policy
)) / 2;
45 // Enable FIFO scheduling
47 ACE_OS::sched_params (ACE_Sched_Params (policy
,
52 if (ACE_OS::last_error () == EPERM
)
55 "client (%P|%t): user is not superuser, "
56 "test runs in time-shared class\n"));
60 "client (%P|%t): sched_params failed %p\n",
64 // Get our thread handle.
66 ACE_OS::thr_self (self
);
68 // Set our thread priority.
69 if (ACE_OS::thr_setprio (self
, priority
) != 0)
71 "server (%P|%t):thr_setprio failed %p\n",
75 if (ACE_OS::thr_getprio (self
, priority
) == 0)
77 "client (%P|%t): thread priority = %d.\n",
84 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
86 int result
= set_rt_mode ();
93 CORBA::ORB_init (argc
,
96 // Get the command line options.
97 if (parse_args (argc
, argv
) != 0)
99 ACE_ERROR_RETURN ((LM_ERROR
,
100 "parse_args failed\n"),
104 CORBA::Object_var poa_object
=
105 orb
->resolve_initial_references ("RootPOA");
107 PortableServer::POA_var root_poa
=
108 PortableServer::POA::_narrow (poa_object
.in ());
110 PortableServer::POAManager_var poa_manager
=
111 root_poa
->the_POAManager ();
113 Test_i
server_impl (orb
.in ());
116 server_impl
._this ();
118 CORBA::String_var ior
=
119 orb
->object_to_string (server
.in ());
121 ACE_DEBUG ((LM_DEBUG
,
122 "Activated as <%C>\n",
125 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
127 if (output_file
== 0)
128 ACE_ERROR_RETURN ((LM_ERROR
,
129 "Cannot open output file for writing IOR: %s",
133 ACE_OS::fprintf (output_file
,
137 ACE_OS::fclose (output_file
);
139 poa_manager
->activate ();
143 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
145 root_poa
->destroy (true, true);
147 catch (const CORBA::Exception
& ex
)
149 ex
._tao_print_exception ("server");