2 #include "ace/Get_Opt.h"
4 #include "ace/OS_NS_unistd.h"
6 class Pinger
: public ACE_Task_Base
15 Pinger (CORBA::ORB_var
&orb
, const char *ior
)
25 bool keep_going
= true;
26 while (keep_going
&& !this->stop_
)
30 CORBA::Object_var tmp
= this->orb_
->string_to_object(this->ior_
);
32 Test::IORTable_Shutdown_Race_var target
=
33 Test::IORTable_Shutdown_Race::_narrow(tmp
.in ());
34 if (CORBA::is_nil (target
.in ()))
35 ACE_ERROR_RETURN ((LM_DEBUG
,
36 "(%P|%t) Nil target reference <%s>\n",
40 if (this->do_shutdown_
)
42 ACE_DEBUG ((LM_DEBUG
,"(%P|%t) Calling shutdown\n"));
43 this->do_shutdown_
= false;
47 catch (const CORBA::Exception
&ex
)
50 "(%P|%t) caught an exception - %C\n",ex
._name()));
69 ACE_TCHAR
const * target_host
= ACE_TEXT("localhost");
72 parse_args (int argc
, ACE_TCHAR
*argv
[])
74 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("p:h:"));
77 while ((c
= get_opts ()) != -1)
81 port
= ACE_OS::atoi (get_opts
.opt_arg ());
84 target_host
= get_opts
.opt_arg ();
88 ACE_ERROR_RETURN ((LM_ERROR
,
95 // Indicates successful parsing of the command line
100 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
105 CORBA::ORB_init (argc
, argv
);
107 if (parse_args (argc
, argv
) != 0)
111 ACE_OS::sprintf (ior
, "corbaloc::%s:%d/Racer",
112 ACE_TEXT_ALWAYS_CHAR (target_host
), port
);
114 Pinger
pinger(orb
, ior
);
118 ACE_DEBUG ((LM_DEBUG
,"(%P|%t) client - starting client threads\n"));
120 pinger
.activate (THR_NEW_LWP
| THR_JOINABLE
, 5);
124 ACE_DEBUG ((LM_DEBUG
,"(%P|%t) client - All running, time to shutdown server\n"));
129 ACE_DEBUG ((LM_DEBUG
,"(%P|%t) client - Stopping client threads\n"));
133 ACE_DEBUG ((LM_DEBUG
,"(%P|%t) client done\n"));
135 catch (const CORBA::Exception
&ex
)
137 ACE_DEBUG ((LM_DEBUG
,"Main caught %s\n",ex
._name()));