summaryrefslogtreecommitdiff
path: root/TAO/tests/Bug_1551_Regression/Reply_Handler.cpp
blob: 777dfd899cc2f14b470d2be14868aed9584ea8c5 (plain)
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
//
// $Id$
//

#include "Reply_Handler.h"

ACE_RCSID(Bug_1XXX_Regression, Reply_Handler, "$Id$")

Reply_Handler::Reply_Handler (
    Test::Hello_ptr hello, CORBA::ORB_ptr orb)
  : counter_(1000)
  , hello_(Test::Hello::_duplicate(hello))
  , orb_ (CORBA::ORB::_duplicate (orb))
{
}

void
Reply_Handler::short_sleep (void)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  check_counter();

  Test::AMI_HelloHandler_var current =
    _this();

  hello_->sendc_short_sleep(current.in());
}

void
Reply_Handler::short_sleep_excep (
    ::Messaging::ExceptionHolder *ex)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  check_counter();

  try
    {
      if (ex)
        {
          ex->raise_exception ();
        }
      else
        {
          // Problem with the exceptionholder, instead of crashing, print
          // an error to the log, this normally shouldn't happen but when
          // there is a bug in TAO it can happen :-(
          ACE_ERROR ((LM_ERROR, "ERROR: Got nill exceptionholder\n"));
        }
    }
  catch (const CORBA::Exception& ex)
    {
      // Exceptions are expected and thus ignored in normal runs:
#if 0
      ex._tao_print_exception ("(%P|%t) Reply_Handler - caught exception:");
#endif /* 0 */
    }

  Test::AMI_HelloHandler_var current =
    _this();

  hello_->sendc_short_sleep(current.in());
}

void Reply_Handler::
check_counter(void)
{
  long const count = --counter_;
  if(count == 0)
  {
    // ACE_DEBUG((LM_DEBUG, "(%P|%t) Shut down client thread\n"));
    orb_->shutdown(0);
    return;
  }
#if 0
  if(count % 100 == 0)
  {
    ACE_DEBUG((LM_DEBUG, "(%P|%t) count = %d\n", count));
  }
#endif /* 0 */
}