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
|
// $Id$
#include "DII_Reply_Dispatcher.h"
ACE_RCSID(DynamicInterface, DII_Reply_Dispatcher, "$Id$")
#include "Request.h"
#include "tao/Pluggable.h"
#include "tao/Environment.h"
#include "tao/GIOP_Message_State.h"
#include "tao/debug.h"
#include "tao/ORB_Core.h"
#include "tao/Pluggable_Messaging_Utils.h"
// Constructor.
TAO_DII_Deferred_Reply_Dispatcher::TAO_DII_Deferred_Reply_Dispatcher (
const CORBA::Request_ptr req,
TAO_ORB_Core *orb_core)
: TAO_Asynch_Reply_Dispatcher_Base (orb_core),
reply_cdr_ (orb_core->create_input_cdr_data_block (ACE_CDR::DEFAULT_BUFSIZE),
TAO_ENCAP_BYTE_ORDER,
orb_core),
req_ (req)
{
}
// Destructor.
TAO_DII_Deferred_Reply_Dispatcher::~TAO_DII_Deferred_Reply_Dispatcher (void)
{
}
// Dispatch the reply.
int
TAO_DII_Deferred_Reply_Dispatcher::dispatch_reply (
TAO_Pluggable_Reply_Params ¶ms
)
{
this->reply_status_ = params.reply_status_;
// Steal the buffer so that no copying is done.
this->reply_cdr_.steal_from (params.input_cdr_);
// Steal the buffer, that way we don't do any unnecesary copies of
// this data.
CORBA::ULong max = params.svc_ctx_.maximum ();
CORBA::ULong len = params.svc_ctx_.length ();
IOP::ServiceContext* context_list = params.svc_ctx_.get_buffer (1);
this->reply_service_info_.replace (max, len, context_list, 1);
if (TAO_debug_level >= 4)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P | %t):TAO_Asynch_Reply_Dispatcher::dispatch_reply:\n")));
}
ACE_TRY_NEW_ENV
{
// Call the Request back and send the reply data.
this->req_->handle_response (this->reply_cdr_,
this->reply_status_,
ACE_TRY_ENV);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
if (TAO_debug_level >= 4)
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
"Exception during reply handler");
}
}
ACE_ENDTRY;
// This was dynamically allocated. Now the job is done. Commit
// suicide here.
delete this;
return 1;
}
void
TAO_DII_Deferred_Reply_Dispatcher::connection_closed (void)
{
ACE_TRY_NEW_ENV
{
// Generate a fake exception....
CORBA::COMM_FAILURE comm_failure (0,
CORBA::COMPLETED_MAYBE);
TAO_OutputCDR out_cdr;
comm_failure._tao_encode (out_cdr,
ACE_TRY_ENV);
ACE_TRY_CHECK;
// Turn into an output CDR
TAO_InputCDR cdr (out_cdr);
this->req_->handle_response (cdr,
TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION,
ACE_TRY_ENV);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
if (TAO_debug_level >= 4)
{
ACE_PRINT_EXCEPTION (
ACE_ANY_EXCEPTION,
"DII_Deferred_Reply_Dispacher::connection_closed"
);
}
}
ACE_ENDTRY;
}
|