2 #include "ace/Get_Opt.h"
4 #include "ace/Barrier.h"
5 #include "ace/OS_NS_unistd.h"
6 #include "ace/OS_NS_strings.h"
8 #include "tao/ORB_Core.h"
9 #include "tao/Transport_Cache_Manager.h"
10 #include "tao/Thread_Lane_Resources.h"
12 const ACE_TCHAR
*ior1
= ACE_TEXT ("file://server1.ior");
13 const ACE_TCHAR
*ior2
= ACE_TEXT ("file://server2.ior");
19 ACE_Barrier
barrier(2);
22 parse_args (int argc
, ACE_TCHAR
*argv
[])
24 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT ("k:l:d:"));
27 while ((c
= get_opts ()) != -1)
31 ior1
= get_opts
.opt_arg ();
35 ior2
= get_opts
.opt_arg ();
38 debug_level
= ACE_OS::atoi( get_opts
.opt_arg ());
42 ACE_ERROR_RETURN ((LM_ERROR
,
43 ACE_TEXT ("usage: %s ")
44 ACE_TEXT ("-k <ior1>\n")
45 ACE_TEXT ("-l <ior2>\n"),
46 ACE_TEXT ("-d <debug_level>\n"),
50 // Indicates successful parsing of the command line
56 test_server (void *arg
)
58 intptr_t server_nr
= reinterpret_cast<intptr_t> (arg
);
63 ACE_OS::sprintf(ior
, ACE_TEXT ("%s"), ior1
);
64 else if (server_nr
== 2)
66 ACE_OS::sprintf(ior
, ACE_TEXT ("%s"), ior2
);
68 ACE_TEXT("%D Expecting an exception for server %d\n"),
72 Test::Hello_var hello
;
76 ACE_TEXT ("%D Starting connection with server %d\n"),
79 CORBA::Object_var server
= orb
->string_to_object(ior
);
81 hello
= Test::Hello::_narrow(server
.in ());
83 if (CORBA::is_nil (hello
.in ()))
87 ACE_TEXT ("%D (%t) Nil Test::Hello reference <%s> for server %d\n"),
93 ACE_TEXT ("%D Transport data before invocation to server %d: current size: %d\n"),
95 orb
->orb_core ()->lane_resources ().transport_cache ().current_size ()));
97 CORBA::String_var the_string
= hello
->get_string ();
100 ACE_TEXT ("%D Transport data after invocation to server %d: current size: %d\n"),
102 orb
->orb_core ()->lane_resources ().transport_cache ().current_size ()));
104 ACE_DEBUG ((LM_DEBUG
,
105 ACE_TEXT ("%D (%P|%t) - string <%C> returned from server %d\n"),
106 the_string
.in (), server_nr
));
108 catch (const CORBA::TRANSIENT
&e
)
113 ACE_TEXT ("%D Expected exception for server %d: %C\n"),
120 ACE_TEXT ("%D Unexpected exception for server %d: %C\n"),
128 ACE_TEXT ("%D Unexpected exception for server %d\n"),
136 ACE_DEBUG ((LM_DEBUG
,
137 ACE_TEXT ("%D Shutdown server %d\n"),
140 if (!CORBA::is_nil(hello
.in ()))
154 ACE_DEBUG ((LM_DEBUG
,
155 ACE_TEXT ("%D Thread ended for server %d\n"),
162 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
168 if (parse_args (argc
, argv
) != 0)
174 ACE_TCHAR
**extra
= 0;
175 ACE_NEW_RETURN (extra
, ACE_TCHAR
*[extra_argc
], -1);
176 extra
[0] = ACE::strnew (ACE_TEXT ("-ORBSvcConfDirective"));
177 extra
[1] = ACE::strnew (ACE_TEXT ("static Resource_Factory \"-ORBConnectionCacheMax 1 -ORBConnectionCachePurgePercentage 100\""));
178 extra
[2] = ACE::strnew (ACE_TEXT ("-ORBSvcConfDirective"));
179 extra
[3] = ACE::strnew (ACE_TEXT ("static Client_Strategy_Factory \"-ORBTransportMuxStrategy EXCLUSIVE\""));
182 extra
[4] = ACE::strnew (ACE_TEXT ("-ORBdebuglevel"));
183 extra
[5] = ACE::strnew (ACE_TEXT ("10"));
186 ACE_TCHAR
**largv
= new ACE_TCHAR
*[argc
+extra_argc
];
187 for (int i
= 0; i
< argc
; i
++)
190 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%D client adding args:\n")));
191 for (int i
= 0; i
< extra_argc
; i
++)
193 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\t\t%s\n"), extra
[i
]));
194 largv
[argc
+i
] = extra
[i
];
199 orb
= CORBA::ORB_init (argc
, largv
);
201 if (ACE_Thread_Manager::instance ()->spawn
202 ((ACE_THR_FUNC
) test_server
,
204 THR_NEW_LWP
| THR_JOINABLE
,
207 ACE_ERROR_RETURN ((LM_ERROR
,
208 ACE_TEXT ("Error spawning thread 1\n")),
214 if (ACE_Thread_Manager::instance ()->spawn
215 ((ACE_THR_FUNC
) test_server
,
217 THR_NEW_LWP
| THR_JOINABLE
,
220 ACE_ERROR_RETURN ((LM_ERROR
,
221 ACE_TEXT ("Error spawning thread 2")),
225 ACE_Thread_Manager::instance()->wait ();
228 ACE_TEXT ("%D Transport data when done: current size: %d\n"),
229 orb
->orb_core ()->lane_resources ().transport_cache ().current_size ()));
232 for (int i
= 0; i
< extra_argc
; i
++)
233 ACE::strdelete (extra
[i
]);
237 catch (const CORBA::Exception
& ex
)
239 ex
._tao_print_exception ("Exception caught:");