summaryrefslogtreecommitdiff
path: root/TAO/tests/Nested_Upcall_Crash/Server_Peer.cpp
blob: 36c6ad2d83b046a0a174c0e4c9270d3bd61375e7 (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
/**
 * @file Server_Peer.cpp
 *
 * $Id$
 *
 * @author Carlos O'Ryan <coryan@atdesk.com>
 *
 */
#include "Server_Peer.h"
#include "tao/debug.h"

ACE_RCSID(Nested_Upcall_Crash, Server_Peer, "$Id$")

Server_Peer::Server_Peer (ACE_RANDR_TYPE seed,
                          CORBA::ORB_ptr orb,
                          CORBA::ULong payload_size)
  : seed_ (seed)
  , orb_ (CORBA::ORB::_duplicate(orb))
  , payload_size_ (payload_size)
{
}

void
Server_Peer::callme(Test::Peer_ptr callback,
                    CORBA::ULong max_depth,
                    Test::Payload const &)
  ACE_THROW_SPEC((CORBA::SystemException))
{
  int r = ACE_OS::rand_r(this->seed_) % 50;

  if(TAO_debug_level)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "(%P|%t) Server_Peer::callme[%d], r = %d\n",
                  max_depth, r));
    }

  if(r == 0)
  {
    try
    {
      callback->crash();
    }
    catch (const CORBA::Exception&)
    {
    }

    // orb_->shutdown (0);
  }
  else if (max_depth > 0)
  {
    Test::Peer_var me =
      this->_this();

    Test::Payload extra_data(this->payload_size_);
    extra_data.length(this->payload_size_);
    callback->callme(me.in(),
                     max_depth - 1,
                     extra_data);
  }
}

void
Server_Peer::crash(void)
  ACE_THROW_SPEC((CORBA::SystemException))
{
  throw CORBA::NO_IMPLEMENT ();
}

void
Server_Peer::noop(void)
  ACE_THROW_SPEC((CORBA::SystemException))
{
}