1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/**
* @file Client_Task.cpp
* @author Will Otte <wotte@dre.vanderbilt.edu
*
* $Id$
*
* Implements the Client_Task class defined in Client_Task.h.
*/
#include "Client_Task.h"
#include "testC.h"
#include "Client_ORBInitializer.h"
Client_Task::Client_Task (const char *input,
CORBA::ORB_ptr corb,
ACE_Thread_Manager *thr_mgr)
: ACE_Task_Base (thr_mgr),
input_ (input),
corb_ (CORBA::ORB::_duplicate (corb))
{}
int
Client_Task::svc (void)
{
ACE_TRY_NEW_ENV
{
CORBA::Object_var object =
corb_->string_to_object (input_ ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
Bug1495_Regression::Bug1495_var server =
Bug1495_Regression::Bug1495::_narrow (object.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR ((LM_ERROR,
"Object reference <%s> is nil\n",
input_));
return 1;
}
// Try multiple calls to see if we keep being forwarded
for (int i = 0; i < 5; i++)
{
// call the thread_id function on the test object
CORBA::Long remote_thread_id;
server->get_thread_id (remote_thread_id ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
ACE_DEBUG ((LM_INFO,
"Remote thread ID was %i\n",
remote_thread_id));
CORBA::Long mythread_id = (CORBA::Long)ACE_Thread::self();
if (mythread_id != remote_thread_id)
{
ACE_ERROR ((LM_ERROR,
"ERROR: Failed Bug_1495_Regression test. "
"Expected thread id was %i, received %i.\n",
mythread_id,
remote_thread_id));
}
else
{
ACE_DEBUG ((LM_INFO,
"Passed Bug_1495_Regression test.\n"
"Local thread id was %i, received %i.\n",
mythread_id,
remote_thread_id));
}
}
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
"Caught exception in client task:");
return 1;
}
ACE_ENDTRY;
return 0;
}
|