Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Nested_Upcall_Crash / scavenger.cpp
blobe548316cdc5f2d54bea8b686f468e79f040f93d7
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 #if defined (ACE_OPENVMS)
10 // need this to circumvent link error on OpenVMS
11 // has to do with interference in template instantiations
12 // because multiple executables are build in one directory
13 // reuising eachothers object files.
14 ACE_Time_Value dum = ACE_Time_Value::zero;
15 #endif
17 int
18 parse_args (int argc, ACE_TCHAR *argv[]);
20 int
21 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
23 int ret_val = 0;
25 try
27 CORBA::ORB_var orb =
28 CORBA::ORB_init (argc, argv);
30 CORBA::Object_var object =
31 orb->resolve_initial_references ("PolicyCurrent");
33 CORBA::PolicyCurrent_var policy_current =
34 CORBA::PolicyCurrent::_narrow (object.in ());
36 if (CORBA::is_nil (policy_current.in ()))
38 ACE_ERROR ((LM_ERROR, "ERROR: Nil policy current\n"));
39 return 1;
41 CORBA::Any scope_as_any;
42 scope_as_any <<= Messaging::SYNC_WITH_SERVER;
44 CORBA::PolicyList policies(1); policies.length (1);
45 policies[0] =
46 orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
47 scope_as_any);
49 policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);
51 policies[0]->destroy ();
53 if (parse_args (argc, argv) != 0)
54 return 1;
56 CORBA::Object_var tmp =
57 orb->string_to_object(ior);
59 Test::Peer_var peer =
60 Test::Peer::_narrow(tmp.in ());
62 if (CORBA::is_nil (peer.in ()))
64 ACE_ERROR_RETURN ((LM_DEBUG,
65 "Nil Test::Peer reference <%s>\n",
66 ior),
67 1);
70 while(1)
72 peer->noop ();
75 /* Warning with TRU 64 builds
76 ACE_DEBUG ((LM_DEBUG, "(%P|%t) scavenger - event loop finished\n"));
78 orb->destroy ();
81 catch (const CORBA::Exception& ex)
83 ex._tao_print_exception ("Exception caught:");
84 ret_val = 1;
87 return ret_val;
90 int
91 parse_args (int argc, ACE_TCHAR *argv[])
93 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
94 int c;
96 while ((c = get_opts ()) != -1)
97 switch (c)
99 case 'k':
100 ior = get_opts.opt_arg ();
101 break;
103 case '?':
104 default:
105 ACE_ERROR_RETURN ((LM_ERROR,
106 "usage: %s "
107 "-k <ior> "
108 "\n",
109 argv [0]),
110 -1);
112 // Indicates successful parsing of the command line
113 return 0;