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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#include "Hello_Impl.h"
ACE_Atomic_Op< TAO_SYNCH_MUTEX, u_long > Number_of_Problems = 0uL;
UIPMC_Object_Impl::UIPMC_Object_Impl (CORBA::ULong payload,
CORBA::ULong clients,
CORBA::ULong calls)
: payload_ (payload)
, clients_ (clients)
, calls_ (calls)
{
}
UIPMC_Object_Impl::~UIPMC_Object_Impl (void)
{
if (this->received_.current_size () == 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ERROR: expected %d clients but only %d encountered\n"),
this->clients_, this->received_.current_size ()));
++Number_of_Problems;
return;
}
for (CORBA::ULong i = 0; i < this->clients_; ++i)
{
CORBA::ULong count = 0;
this->received_.find (Test::ClientIDs[i], count);
if (count != this->calls_)
{
// This perfectly ok for MIOP to lose messages.
// So, this is not an error.
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("DEBUG: expected %d messages from '%c' client ")
ACE_TEXT ("but only %d encountered\n"),
this->calls_, Test::ClientIDs[i], count));
++Number_of_Problems;
}
}
}
void
UIPMC_Object_Impl::process (Test::Octets const &payload)
{
if (this->payload_ != payload.length ())
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ERROR: expected %d but received %d ")
ACE_TEXT ("sequence length\n"),
this->payload_, payload.length ()));
++Number_of_Problems;
return;
}
CORBA::ULong count = 0;
CORBA::Octet c = payload[0];
this->received_.find (c, count);
Test::Octets seq (this->payload_);
seq.length (this->payload_);
CORBA::Octet *buff = seq.get_buffer ();
ACE_OS::memset (buff, c, this->payload_);
char *one = static_cast<char *> (static_cast<void *> (buff));
char const *two = static_cast<char const *> (
static_cast<void const *> (payload.get_buffer ()));
if (ACE_OS::strncmp (one, two, this->payload_) != 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ERROR: received malformed message from client '%c'\n"),
c));
++Number_of_Problems;
return;
}
if (ACE_OS::strchr (Test::ClientIDs, c) == 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ERROR: client id '%c' doesn't match any known value\n"),
c));
++Number_of_Problems;
return;
}
++count;
if (this->received_.rebind (c, count) == -1)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ERROR: cann't rebind received count\n")));
++Number_of_Problems;
}
}
Hello_Impl::Hello_Impl (CORBA::ORB_ptr orb,
Test::UIPMC_Object_ptr obj)
: orb_ (CORBA::ORB::_duplicate (orb))
, obj_ (Test::UIPMC_Object::_duplicate (obj))
{
}
Test::UIPMC_Object_ptr
Hello_Impl::get_object (void)
{
return Test::UIPMC_Object::_duplicate (this->obj_.in ());
}
void
Hello_Impl::shutdown (void)
{
try
{
this->orb_->shutdown (false);
}
catch (const CORBA::Exception& ex)
{
++Number_of_Problems;
ex._tao_print_exception ("Exception caught in shutdown():");
}
}
|