1 #include "tao/Synch_Reply_Dispatcher.h"
2 #include "tao/ORB_Core.h"
3 #include "tao/Pluggable_Messaging_Utils.h"
6 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
9 TAO_Synch_Reply_Dispatcher::TAO_Synch_Reply_Dispatcher (
10 TAO_ORB_Core
*orb_core
,
11 IOP::ServiceContextList
&sc
13 : reply_service_info_ (sc
),
16 ACE_Message_Block::MB_DATA
,
18 this->orb_core_
->input_cdr_buffer_allocator (),
19 this->orb_core_
->locking_strategy (),
20 ACE_Message_Block::DONT_DELETE
,
21 this->orb_core_
->input_cdr_dblock_allocator ()),
23 ACE_Message_Block::DONT_DELETE
,
29 // As a TAO_LF_Event we start in the active state....
30 this->state_changed_i (TAO_LF_Event::LFS_ACTIVE
);
34 TAO_Synch_Reply_Dispatcher::~TAO_Synch_Reply_Dispatcher ()
39 TAO_Synch_Reply_Dispatcher::reply_cdr ()
41 return this->reply_cdr_
;
45 TAO_Synch_Reply_Dispatcher::reply_timed_out ()
51 TAO_Synch_Reply_Dispatcher::dispatch_reply (
52 TAO_Pluggable_Reply_Params
¶ms
)
54 if (params
.input_cdr_
== nullptr)
57 this->reply_status_
= params
.reply_status ();
58 this->locate_reply_status_
= params
.locate_reply_status ();
60 // Steal the buffer, that way we don't do any unnecessary copies of
62 CORBA::ULong
const max
= params
.svc_ctx_
.maximum ();
63 CORBA::ULong
const len
= params
.svc_ctx_
.length ();
64 IOP::ServiceContext
* context_list
= params
.svc_ctx_
.get_buffer (true);
65 this->reply_service_info_
.replace (max
, len
, context_list
, true);
67 if (this->reply_service_info_
.length() > 0)
69 orb_core_
->service_context_registry ().
70 process_service_contexts (this->reply_service_info_
, *(params
.transport_
), nullptr);
73 // Must reset the message state, it is possible that the same reply
74 // dispatcher is used because the request must be re-sent.
75 // this->message_state_.reset (0);
77 // Transfer the <params.input_cdr_>'s content to this->reply_cdr_
78 if (ACE_BIT_DISABLED ((*params
.input_cdr_
).start()->data_block()->flags(),
79 ACE_Message_Block::DONT_DELETE
))
81 // Data block is on the heap, so just duplicate it.
82 this->reply_cdr_
= *params
.input_cdr_
;
83 this->reply_cdr_
.clr_mb_flags (ACE_Message_Block::DONT_DELETE
);
87 ACE_Data_Block
*db
= this->reply_cdr_
.clone_from (*params
.input_cdr_
);
91 if (TAO_debug_level
> 2)
93 TAOLIB_ERROR ((LM_ERROR
,
94 "TAO (%P|%t) - Synch_Reply_Dispatcher::dispatch_reply "
95 "clone_from failed\n"));
100 // See whether we need to delete the data block by checking the
101 // flags. We cannot be happy that we initally allocated the
102 // datablocks of the stack. If this method is called twice, as is in
103 // some cases where the same invocation object is used to make two
104 // invocations like forwarding, the release becomes essential.
105 if (ACE_BIT_DISABLED (db
->flags (),
106 ACE_Message_Block::DONT_DELETE
))
112 this->state_changed (TAO_LF_Event::LFS_SUCCESS
,
113 this->orb_core_
->leader_follower ());
119 TAO_Synch_Reply_Dispatcher::connection_closed ()
121 this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSED
,
122 this->orb_core_
->leader_follower ());
125 TAO_END_VERSIONED_NAMESPACE_DECL