summaryrefslogtreecommitdiff
path: root/TAO/tests/Bug_1551_Regression/Reply_Handler.cpp
blob: c6f274953fe4647794e6a7a61ab43db749e0f70f (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
81
82
83
84
85
86
87
88
89
90
91
92
//
// $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 (ACE_ENV_SINGLE_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  check_counter(ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK;

  Test::AMI_HelloHandler_var current =
    _this(ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK;

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

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

  ACE_TRY
    {
      if (ex)
        {
          ex->raise_exception (ACE_ENV_SINGLE_ARG_PARAMETER);
          ACE_TRY_CHECK;
        }
      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"));
        }
    }
  ACE_CATCHANY
    {
      // Exceptions are expected and thus ignored in normal runs:
#if 0
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                           "(%P|%t) Reply_Handler - caught exception:");
#endif /* 0 */
    }
  ACE_ENDTRY;
  ACE_CHECK;

  Test::AMI_HelloHandler_var current =
    _this(ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK;

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

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