Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Nested_Upcall_Crash / scavenger.cpp
blob3c250bfc2f320c38e27f63ff715c1240cfc698fb
1 #include "TestC.h"
2 #include "tao/Messaging/Messaging.h"
3 #include "tao/AnyTypeCode/Any.h"
4 #include "tao/ORB_Core.h"
5 #include "ace/Get_Opt.h"
7 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
9 int
10 parse_args (int argc, ACE_TCHAR *argv[]);
12 int
13 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
15 int ret_val = 0;
17 try
19 CORBA::ORB_var orb =
20 CORBA::ORB_init (argc, argv);
22 CORBA::Object_var object =
23 orb->resolve_initial_references ("PolicyCurrent");
25 CORBA::PolicyCurrent_var policy_current =
26 CORBA::PolicyCurrent::_narrow (object.in ());
28 if (CORBA::is_nil (policy_current.in ()))
30 ACE_ERROR ((LM_ERROR, "ERROR: Nil policy current\n"));
31 return 1;
33 CORBA::Any scope_as_any;
34 scope_as_any <<= Messaging::SYNC_WITH_SERVER;
36 CORBA::PolicyList policies(1); policies.length (1);
37 policies[0] =
38 orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
39 scope_as_any);
41 policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);
43 policies[0]->destroy ();
45 if (parse_args (argc, argv) != 0)
46 return 1;
48 CORBA::Object_var tmp =
49 orb->string_to_object(ior);
51 Test::Peer_var peer =
52 Test::Peer::_narrow(tmp.in ());
54 if (CORBA::is_nil (peer.in ()))
56 ACE_ERROR_RETURN ((LM_DEBUG,
57 "Nil Test::Peer reference <%s>\n",
58 ior),
59 1);
62 while(1)
64 peer->noop ();
67 /* Warning with TRU 64 builds
68 ACE_DEBUG ((LM_DEBUG, "(%P|%t) scavenger - event loop finished\n"));
70 orb->destroy ();
73 catch (const CORBA::Exception& ex)
75 ex._tao_print_exception ("Exception caught:");
76 ret_val = 1;
79 return ret_val;
82 int
83 parse_args (int argc, ACE_TCHAR *argv[])
85 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
86 int c;
88 while ((c = get_opts ()) != -1)
89 switch (c)
91 case 'k':
92 ior = get_opts.opt_arg ();
93 break;
95 case '?':
96 default:
97 ACE_ERROR_RETURN ((LM_ERROR,
98 "usage: %s "
99 "-k <ior> "
100 "\n",
101 argv [0]),
102 -1);
104 // Indicates successful parsing of the command line
105 return 0;