00001
00002
00003 #include "tao/Synch_Reply_Dispatcher.h"
00004 #include "tao/ORB_Core.h"
00005 #include "tao/Pluggable_Messaging_Utils.h"
00006 #include "tao/debug.h"
00007
00008
00009 ACE_RCSID (tao,
00010 Synch_Reply_Dispatcher,
00011 "$Id: Synch_Reply_Dispatcher.cpp 79705 2007-09-24 07:45:37Z johnnyw $")
00012
00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00014
00015
00016 TAO_Synch_Reply_Dispatcher::TAO_Synch_Reply_Dispatcher (
00017 TAO_ORB_Core *orb_core,
00018 IOP::ServiceContextList &sc
00019 )
00020 : reply_service_info_ (sc),
00021 orb_core_ (orb_core),
00022 db_ (sizeof buf_,
00023 ACE_Message_Block::MB_DATA,
00024 this->buf_,
00025 this->orb_core_->input_cdr_buffer_allocator (),
00026 this->orb_core_->locking_strategy (),
00027 ACE_Message_Block::DONT_DELETE,
00028 this->orb_core_->input_cdr_dblock_allocator ()),
00029 reply_cdr_ (&db_,
00030 ACE_Message_Block::DONT_DELETE,
00031 TAO_ENCAP_BYTE_ORDER,
00032 TAO_DEF_GIOP_MAJOR,
00033 TAO_DEF_GIOP_MINOR,
00034 orb_core)
00035 {
00036
00037 this->state_changed_i (TAO_LF_Event::LFS_ACTIVE);
00038 }
00039
00040
00041 TAO_Synch_Reply_Dispatcher::~TAO_Synch_Reply_Dispatcher (void)
00042 {
00043 }
00044
00045 TAO_InputCDR &
00046 TAO_Synch_Reply_Dispatcher::reply_cdr (void)
00047 {
00048 return this->reply_cdr_;
00049 }
00050
00051 int
00052 TAO_Synch_Reply_Dispatcher::dispatch_reply (
00053 TAO_Pluggable_Reply_Params ¶ms)
00054 {
00055 if (params.input_cdr_ == 0)
00056 return -1;
00057
00058 this->reply_status_ = params.reply_status ();
00059 this->locate_reply_status_ = params.locate_reply_status ();
00060
00061
00062
00063 CORBA::ULong const max = params.svc_ctx_.maximum ();
00064 CORBA::ULong const len = params.svc_ctx_.length ();
00065 IOP::ServiceContext* context_list = params.svc_ctx_.get_buffer (1);
00066 this->reply_service_info_.replace (max, len, context_list, 1);
00067
00068
00069
00070
00071
00072
00073 if (ACE_BIT_DISABLED ((*params.input_cdr_).start()->data_block()->flags(),
00074 ACE_Message_Block::DONT_DELETE))
00075 {
00076
00077 this->reply_cdr_ = *params.input_cdr_;
00078 this->reply_cdr_.clr_mb_flags( ACE_Message_Block::DONT_DELETE );
00079 }
00080 else
00081 {
00082 ACE_Data_Block *db = this->reply_cdr_.clone_from (*params.input_cdr_);
00083
00084 if (db == 0)
00085 {
00086 if (TAO_debug_level > 2)
00087 {
00088 ACE_ERROR ((LM_ERROR,
00089 "TAO (%P|%t) - Synch_Reply_Dispatcher::dispatch_reply "
00090 "clone_from failed \n"));
00091 }
00092 return -1;
00093 }
00094
00095
00096
00097
00098
00099
00100 if (ACE_BIT_DISABLED (db->flags (),
00101 ACE_Message_Block::DONT_DELETE))
00102 {
00103 db->release ();
00104 }
00105 }
00106
00107 this->state_changed (TAO_LF_Event::LFS_SUCCESS,
00108 this->orb_core_->leader_follower ());
00109
00110 return 1;
00111 }
00112
00113 void
00114 TAO_Synch_Reply_Dispatcher::connection_closed (void)
00115 {
00116 this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSED,
00117 this->orb_core_->leader_follower ());
00118 }
00119
00120 TAO_END_VERSIONED_NAMESPACE_DECL