diff options
Diffstat (limited to 'TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp')
-rw-r--r-- | TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp | 141 |
1 files changed, 122 insertions, 19 deletions
diff --git a/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp b/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp index 769a3bd5090..74ae33a1881 100644 --- a/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp +++ b/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp @@ -2,11 +2,10 @@ #include "tao/DynamicInterface/DII_Reply_Dispatcher.h" #include "tao/DynamicInterface/Request.h" -#include "tao/Environment.h" #include "tao/debug.h" #include "tao/ORB_Core.h" #include "tao/Pluggable_Messaging_Utils.h" - +#include "tao/SystemException.h" ACE_RCSID(DynamicInterface, DII_Reply_Dispatcher, @@ -32,8 +31,7 @@ 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 - ) + TAO_Pluggable_Reply_Params ¶ms) { if (params.input_cdr_ == 0) return -1; @@ -41,9 +39,7 @@ TAO_DII_Deferred_Reply_Dispatcher::dispatch_reply ( this->reply_status_ = params.reply_status_; // Transfer the <params.input_cdr_>'s content to this->reply_cdr_ - ACE_Data_Block *db = - this->reply_cdr_.clone_from (*params.input_cdr_); - + ACE_Data_Block *db = this->reply_cdr_.clone_from (*params.input_cdr_); if (db == 0) { @@ -82,11 +78,9 @@ TAO_DII_Deferred_Reply_Dispatcher::dispatch_reply ( try { // Call the Request back and send the reply data. - this->req_->handle_response (this->reply_cdr_, - this->reply_status_ - ); + this->req_->handle_response (this->reply_cdr_, this->reply_status_); } - catch ( ::CORBA::Exception& ex) + catch (const ::CORBA::Exception& ex) { if (TAO_debug_level >= 4) { @@ -107,22 +101,18 @@ TAO_DII_Deferred_Reply_Dispatcher::connection_closed (void) try { // Generate a fake exception.... - CORBA::COMM_FAILURE comm_failure (0, - CORBA::COMPLETED_MAYBE); + CORBA::COMM_FAILURE comm_failure (0, CORBA::COMPLETED_MAYBE); TAO_OutputCDR out_cdr; - comm_failure._tao_encode (out_cdr - ); + comm_failure._tao_encode (out_cdr); // Turn into an output CDR TAO_InputCDR cdr (out_cdr); - this->req_->handle_response (cdr, - TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION - ); + this->req_->handle_response (cdr, TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION); } - catch ( ::CORBA::Exception& ex) + catch (const ::CORBA::Exception& ex) { if (TAO_debug_level >= 4) { @@ -134,4 +124,117 @@ TAO_DII_Deferred_Reply_Dispatcher::connection_closed (void) (void) this->decr_refcount (); } +TAO_DII_Asynch_Reply_Dispatcher::TAO_DII_Asynch_Reply_Dispatcher ( + const Messaging::ReplyHandler_ptr callback, + TAO_ORB_Core *orb_core) + : TAO_Asynch_Reply_Dispatcher_Base (orb_core), + db_ (sizeof buf_, + ACE_Message_Block::MB_DATA, + this->buf_, + orb_core->input_cdr_buffer_allocator (), + orb_core->locking_strategy (), + ACE_Message_Block::DONT_DELETE, + orb_core->input_cdr_dblock_allocator ()), + reply_cdr_ (&db_, + ACE_Message_Block::DONT_DELETE, + TAO_ENCAP_BYTE_ORDER, + TAO_DEF_GIOP_MAJOR, + TAO_DEF_GIOP_MINOR, + orb_core), + callback_ (callback) +{ +} + +TAO_DII_Asynch_Reply_Dispatcher::~TAO_DII_Asynch_Reply_Dispatcher (void) +{ + // this was handed to us by the caller. + CORBA::release(callback_); +} + +int +TAO_DII_Asynch_Reply_Dispatcher::dispatch_reply ( + TAO_Pluggable_Reply_Params ¶ms + ) +{ + this->reply_status_ = params.reply_status_; + + // Transfer the <params.input_cdr_>'s content to this->reply_cdr_ + ACE_Data_Block *db = + this->reply_cdr_.clone_from (*params.input_cdr_); + + // See whether we need to delete the data block by checking the + // flags. We cannot be happy that we initally allocated the + // datablocks of the stack. If this method is called twice, as is in + // some cases where the same invocation object is used to make two + // invocations like forwarding, the release becomes essential. + if (ACE_BIT_DISABLED (db->flags (), + ACE_Message_Block::DONT_DELETE)) + db->release (); + + // 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):") + ACE_TEXT ("TAO_DII_Asynch_Reply_Dispatcher::dispatch_reply: status = %d\n"), + this->reply_status_)); + } + + try + { + // Call the handler with the reply data. + CORBA::Request::_tao_reply_stub (this->reply_cdr_, + this->callback_, + this->reply_status_); + } + catch (const CORBA::Exception& ex) + { + if (TAO_debug_level >= 4) + { + ex._tao_print_exception ("Exception during reply handler"); + } + } + // This was dynamically allocated. Now the job is done. + (void) this->decr_refcount (); + + return 1; +} + +void +TAO_DII_Asynch_Reply_Dispatcher::connection_closed (void) +{ + try + { + // Generate a fake exception.... + CORBA::COMM_FAILURE comm_failure (0, + CORBA::COMPLETED_MAYBE); + + TAO_OutputCDR out_cdr; + + comm_failure._tao_encode (out_cdr); + + // Turn into an output CDR + TAO_InputCDR cdr (out_cdr); + CORBA::Request::_tao_reply_stub ( + this->reply_cdr_, + this->callback_, + TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION); + } + catch (const CORBA::Exception& ex) + { + if (TAO_debug_level >= 4) + { + ex._tao_print_exception ( + "DII_Asynch_Reply_Dispacher::connection_closed"); + } + } + + (void) this->decr_refcount (); +} TAO_END_VERSIONED_NAMESPACE_DECL |