Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_2377_Regression / Hello_Impl.cpp
blobb88f0e1d8afc80134460d8f5a6f0666a93141560
2 #include "Hello_Impl.h"
4 Hello_Impl::Hello_Impl (CORBA::ORB_ptr orb, MessageLog *log)
5 : orb_ (CORBA::ORB::_duplicate (orb))
6 , logger_ (log)
10 void
11 Hello_Impl::say_hello (CORBA::Short count)
13 this->logger_->register_message_recv (count);
16 void
17 Hello_Impl::shutdown ()
19 try
21 this->orb_->shutdown (false);
23 catch (const CORBA::Exception& ex)
25 //FUZZ: disable check_for_lack_ACE_OS
26 ex._tao_print_exception ("Exception caught in shutdown ():");
27 //FUZZ: enable check_for_lack_ACE_OS
31 MessageLog::MessageLog (int num, bool sprs)
32 : expected_ (num)
33 , overdoseS_ (0)
34 , overdoseR_ (0)
35 , supress_ (sprs)
37 this->sent_ = new int[this->expected_];
38 this->rcvd_ = new int[this->expected_];
40 int i;
41 for (i = 0; i < this->expected_; i++)
43 this->sent_[i] = 0;
44 this->rcvd_[i] = 0;
48 MessageLog::~MessageLog ()
50 delete [] this->sent_;
51 delete [] this->rcvd_;
54 void
55 MessageLog::register_message_send (int message_num)
57 ACE_GUARD (ACE_Mutex, ace_mon, this->mutex_);
58 if (0 <= message_num && message_num < this->expected_)
60 this->sent_[message_num]++;
62 else
64 this->overdoseS_++;
67 if (!this->supress_)
69 ACE_DEBUG ((LM_DEBUG,
70 "%02d>>; ",
71 message_num));
75 void
76 MessageLog::register_message_recv (int message_num)
78 ACE_GUARD (ACE_Mutex, ace_mon, this->mutex_);
79 if (0 <= message_num && message_num < this->expected_)
81 this->rcvd_[message_num]++;
83 else
85 this->overdoseR_++;
88 if (!this->supress_)
90 ACE_DEBUG ((LM_DEBUG,
91 "%02d<<; ",
92 message_num));
96 int
97 MessageLog::report_statistics ()
99 int i;
100 int lmco = 0;
102 for (i = 0; i < this->expected_; i++)
104 lmco += this->sent_[i] - this->rcvd_[i];
106 if (this->sent_[i] > 1 && !this->supress_)
108 ACE_DEBUG ((LM_DEBUG,
109 "\nSENT message <<< %d >>> %d times",
110 i, this->sent_[i]));
113 if (this->rcvd_[i] > 1 && !this->supress_)
115 ACE_DEBUG ((LM_DEBUG,
116 "\nRECEIVED message <<< %d >>> %d times",
117 i, this->rcvd_[i]));
120 if (this->sent_[i] != this->rcvd_[i] && !this->supress_)
122 ACE_DEBUG ((LM_DEBUG,
123 "\nLOST message <<< %d >>> %d times",
124 i, this->sent_[i] - this->rcvd_[i]));
128 if (this->overdoseS_ != 0 && !this->supress_)
130 ACE_DEBUG ((LM_DEBUG,
131 "\nSent more than expected."));
134 if (this->overdoseR_ != 0 && !this->supress_)
136 ACE_DEBUG ((LM_DEBUG,
137 "\nReceived more than expected."));
140 return lmco;