diff options
26 files changed, 222 insertions, 44 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 80b564dae93..48226158a3c 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,42 @@ +Fri Jun 26 20:41:53 UTC 2009 Adam Mitz <mitza@ociweb.com> + + * tao/Block_Flushing_Strategy.h: + * tao/Block_Flushing_Strategy.cpp: + * tao/Connection_Handler.h: + * tao/Connection_Handler.inl: + * tao/Connection_Handler.cpp: + * tao/IIOP_Connection_Handler.h: + * tao/IIOP_Connection_Handler.cpp: + * tao/Transport.h: + * tao/Transport.cpp: + + This resolves bug #3704. + TAO_Transport::handle_output() now uses an enum return value to + distinguish the EWOULDBLOCK case from other normal or error + conditions. The Block_Flushing_Strategy checks for EWOULDBLOCK + and calls a new method, handle_write_ready(), on the Connection + Handler. The Connection Handler calls ACE::handle_write_ready() + passing the specific handle. + + * tao/Strategies/DIOP_Connection_Handler.h: + * tao/Strategies/DIOP_Connection_Handler.cpp: + * tao/Strategies/SCIOP_Connection_Handler.h: + * tao/Strategies/SCIOP_Connection_Handler.cpp: + * tao/Strategies/SHMIOP_Connection_Handler.h: + * tao/Strategies/SHMIOP_Connection_Handler.cpp: + * tao/Strategies/UIOP_Connection_Handler.h: + * tao/Strategies/UIOP_Connection_Handler.cpp: + * orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.h: + * orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp: + * orbsvcs/orbsvcs/PortableGroup/UIPMC_Connection_Handler.h: + * orbsvcs/orbsvcs/PortableGroup/UIPMC_Connection_Handler.cpp: + * orbsvcs/orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.h: + * orbsvcs/orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.cpp: + * orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.h: + * orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp: + + Added handle_write_ready() to the non-IIOP protocols. + Thu Jun 25 14:17:46 UTC 2009 Adam Mitz <mitza@ociweb.com> * TAO_IDL/fe/lex.yy.cpp: diff --git a/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp b/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp index f6d98ad2d85..0dcab5ad0f1 100644 --- a/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp +++ b/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp @@ -304,4 +304,10 @@ TAO::HTIOP::Connection_Handler::set_dscp_codepoint ( return 0; } +int +TAO::HTIOP::Connection_Handler::handle_write_ready (const ACE_Time_Value *t) +{ + return ACE::handle_write_ready (this->peer ().get_handle (), t); +} + TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.h b/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.h index 64a89eca11c..a0abcad5026 100644 --- a/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.h +++ b/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.h @@ -117,6 +117,7 @@ namespace TAO * @name TAO_Connection Handler overloads */ virtual int release_os_resources (void); + virtual int handle_write_ready (const ACE_Time_Value *timeout); //@} private: diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Connection_Handler.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Connection_Handler.cpp index f7ff15edc43..2b28cb7716f 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Connection_Handler.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Connection_Handler.cpp @@ -456,4 +456,10 @@ TAO_UIPMC_Connection_Handler::set_dscp_codepoint (CORBA::Boolean set_network_pri return 0; } +int +TAO_UIPMC_Connection_Handler::handle_write_ready (const ACE_Time_Value *t) +{ + return ACE::handle_write_ready (this->peer ().get_handle (), t); +} + TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Connection_Handler.h b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Connection_Handler.h index 6b8268a11a4..4e4b0e8d8e0 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Connection_Handler.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Connection_Handler.h @@ -132,6 +132,7 @@ protected: * @name TAO_Connection Handler overloads */ virtual int release_os_resources (void); + virtual int handle_write_ready (const ACE_Time_Value *timeout); //@} // helper function used by the set_dscp_codepoint () methods to diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.cpp index b11dca07fda..f9af18c659e 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.cpp @@ -228,4 +228,11 @@ TAO_UIPMC_Mcast_Connection_Handler::add_transport_to_cache (void) this->transport ()); } +int +TAO_UIPMC_Mcast_Connection_Handler::handle_write_ready + (const ACE_Time_Value *t) +{ + return ACE::handle_write_ready (this->peer ().get_handle (), t); +} + TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.h b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.h index fc706df0320..913391e3173 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.h @@ -127,6 +127,7 @@ protected: * @name TAO_Connection Handler overloads */ virtual int release_os_resources (void); + virtual int handle_write_ready (const ACE_Time_Value *timeout); //@} }; diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp index feb250f3849..0636b60f017 100644 --- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp +++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp @@ -440,4 +440,10 @@ TAO::SSLIOP::Connection_Handler::teardown_ssl_state ( this->current_->teardown (previous_current_impl, setup_done); } +int +TAO::SSLIOP::Connection_Handler::handle_write_ready (const ACE_Time_Value *t) +{ + return ACE::handle_write_ready (this->peer ().get_handle (), t); +} + TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.h b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.h index fa8e35deb57..2e4e4d3de95 100644 --- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.h +++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.h @@ -113,6 +113,7 @@ namespace TAO */ virtual int release_os_resources (void); virtual void pos_io_hook (int & return_value); + virtual int handle_write_ready (const ACE_Time_Value *timeout); //@} protected: diff --git a/TAO/tao/Block_Flushing_Strategy.cpp b/TAO/tao/Block_Flushing_Strategy.cpp index 397e4717006..ce17445599d 100644 --- a/TAO/tao/Block_Flushing_Strategy.cpp +++ b/TAO/tao/Block_Flushing_Strategy.cpp @@ -3,6 +3,8 @@ #include "tao/Block_Flushing_Strategy.h" #include "tao/Transport.h" #include "tao/Queued_Message.h" +#include "tao/Connection_Handler.h" +#include "ace/Countdown_Time.h" ACE_RCSID(tao, Block_Flushing_Strategy, "$Id$") @@ -21,15 +23,37 @@ TAO_Block_Flushing_Strategy::cancel_output (TAO_Transport *) } int +TAO_Block_Flushing_Strategy::call_handle_output (TAO_Transport *transport, + const TAO::Transport::Drain_Constraints &dc) +{ + switch (transport->handle_output (dc).dre_) + { + case TAO_Transport::DR_ERROR: return -1; + case TAO_Transport::DR_QUEUE_EMPTY: // won't happen, fall-through anyway + case TAO_Transport::DR_OK: return 0; + case TAO_Transport::DR_WOULDBLOCK: + { + ACE_Countdown_Time counter (dc.timeout ()); + TAO_Connection_Handler &ch = *transport->connection_handler (); + if (ch.handle_write_ready (dc.timeout ()) == -1) + { + return -1; + } + return 0; + } + } + return 0; +} + +int TAO_Block_Flushing_Strategy::flush_message (TAO_Transport *transport, TAO_Queued_Message *msg, ACE_Time_Value *max_wait_time) { + TAO::Transport::Drain_Constraints dc (max_wait_time, true); while (!msg->all_data_sent ()) { - TAO::Transport::Drain_Constraints dc( - max_wait_time, true); - if (transport->handle_output (dc) == -1) + if (this->call_handle_output (transport, dc) == -1) return -1; } return 0; @@ -39,11 +63,10 @@ int TAO_Block_Flushing_Strategy::flush_transport (TAO_Transport *transport, ACE_Time_Value *max_wait_time) { + TAO::Transport::Drain_Constraints dc (max_wait_time, true); while (!transport->queue_is_empty ()) { - TAO::Transport::Drain_Constraints dc( - max_wait_time, true); - if (transport->handle_output (dc) == -1) + if (this->call_handle_output (transport, dc) == -1) return -1; } return 0; diff --git a/TAO/tao/Block_Flushing_Strategy.h b/TAO/tao/Block_Flushing_Strategy.h index b82ec8db0ee..a766e184f30 100644 --- a/TAO/tao/Block_Flushing_Strategy.h +++ b/TAO/tao/Block_Flushing_Strategy.h @@ -22,6 +22,14 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL +namespace TAO +{ + namespace Transport + { + class Drain_Constraints; + } +} + /** * @class TAO_Block_Flushing_Strategy * @@ -37,6 +45,10 @@ public: ACE_Time_Value *max_wait_time); virtual int flush_transport (TAO_Transport *transport , ACE_Time_Value *max_wait_time); + +private: + int call_handle_output (TAO_Transport *transport, + const TAO::Transport::Drain_Constraints &dc); }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/Connection_Handler.cpp b/TAO/tao/Connection_Handler.cpp index 269ffd38024..7945e538cda 100644 --- a/TAO/tao/Connection_Handler.cpp +++ b/TAO/tao/Connection_Handler.cpp @@ -208,7 +208,8 @@ TAO_Connection_Handler::handle_output_eh ( // The default constraints are to never block. TAO::Transport::Drain_Constraints dc; - return_value = this->transport ()->handle_output (dc); + return_value = + (this->transport ()->handle_output (dc) == TAO_Transport::DR_OK) ? 0 : -1; this->pos_io_hook (return_value); diff --git a/TAO/tao/Connection_Handler.h b/TAO/tao/Connection_Handler.h index 39dfd6e7fae..5300641c744 100644 --- a/TAO/tao/Connection_Handler.h +++ b/TAO/tao/Connection_Handler.h @@ -136,6 +136,8 @@ public: /// Release the OS resources related to this handler. virtual int release_os_resources (void); + virtual int handle_write_ready (const ACE_Time_Value *timeout); + /* * Hook to add public methods from concrete connection handler * implementation onto the base connection handler. diff --git a/TAO/tao/Connection_Handler.inl b/TAO/tao/Connection_Handler.inl index 3e3397b282f..5c584b64565 100644 --- a/TAO/tao/Connection_Handler.inl +++ b/TAO/tao/Connection_Handler.inl @@ -64,6 +64,15 @@ TAO_Connection_Handler::cancel_pending_connection (void) } } +/// Derived classes should implement this for proper support with the +/// Blocking Flushing Strategy. +ACE_INLINE int +TAO_Connection_Handler::handle_write_ready (const ACE_Time_Value *) +{ + return 0; +} + + //@@ CONNECTION_HANDLER_SPL_METHODS_ADD_HOOK TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/IIOP_Connection_Handler.cpp b/TAO/tao/IIOP_Connection_Handler.cpp index 78c638a8aa7..1f27c5472fd 100644 --- a/TAO/tao/IIOP_Connection_Handler.cpp +++ b/TAO/tao/IIOP_Connection_Handler.cpp @@ -668,6 +668,13 @@ TAO_IIOP_Connection_Handler::abort (void) } } +int +TAO_IIOP_Connection_Handler::handle_write_ready (const ACE_Time_Value *timeout) +{ + return ACE::handle_write_ready (this->peer ().get_handle (), timeout); +} + + //@@ CONNECTION_HANDLER_SPL_COPY_HOOK_END /* * End copy hook diff --git a/TAO/tao/IIOP_Connection_Handler.h b/TAO/tao/IIOP_Connection_Handler.h index 067c4768be1..a96bf0c8403 100644 --- a/TAO/tao/IIOP_Connection_Handler.h +++ b/TAO/tao/IIOP_Connection_Handler.h @@ -123,6 +123,8 @@ protected: virtual int release_os_resources (void); //@} + virtual int handle_write_ready (const ACE_Time_Value *timeout); + // helper function used by the set_dscp_codepoint () methods to // set the TOS field in the IP packets. int set_tos (int tos); diff --git a/TAO/tao/Strategies/DIOP_Connection_Handler.cpp b/TAO/tao/Strategies/DIOP_Connection_Handler.cpp index 5aa66011513..193d4521af6 100644 --- a/TAO/tao/Strategies/DIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/DIOP_Connection_Handler.cpp @@ -435,6 +435,12 @@ TAO_DIOP_Connection_Handler::set_dscp_codepoint (CORBA::Boolean set_network_prio return 0; } +int +TAO_DIOP_Connection_Handler::handle_write_ready (const ACE_Time_Value *t) +{ + return ACE::handle_write_ready (this->peer ().get_handle (), t); +} + TAO_END_VERSIONED_NAMESPACE_DECL #endif /* TAO_HAS_DIOP && TAO_HAS_DIOP != 0 */ diff --git a/TAO/tao/Strategies/DIOP_Connection_Handler.h b/TAO/tao/Strategies/DIOP_Connection_Handler.h index fd910d0ced8..f54334bed38 100644 --- a/TAO/tao/Strategies/DIOP_Connection_Handler.h +++ b/TAO/tao/Strategies/DIOP_Connection_Handler.h @@ -124,6 +124,7 @@ protected: * @name TAO_Connection Handler overloads */ virtual int release_os_resources (void); + virtual int handle_write_ready (const ACE_Time_Value *timeout); //@} /// Helper method used by the set_dscp_codepoint () methods diff --git a/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp b/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp index 33873fc18bc..c81e4783c9d 100644 --- a/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp @@ -460,6 +460,12 @@ TAO_SCIOP_Connection_Handler::set_dscp_codepoint (CORBA::Boolean set_network_pri return 0; } +int +TAO_SCIOP_Connection_Handler::handle_write_ready (const ACE_Time_Value *t) +{ + return ACE::handle_write_ready (this->peer ().get_handle (), t); +} + TAO_END_VERSIONED_NAMESPACE_DECL #endif /* TAO_HAS_SCIOP == 1 */ diff --git a/TAO/tao/Strategies/SCIOP_Connection_Handler.h b/TAO/tao/Strategies/SCIOP_Connection_Handler.h index 6cdc1f4702c..823e684a3f2 100644 --- a/TAO/tao/Strategies/SCIOP_Connection_Handler.h +++ b/TAO/tao/Strategies/SCIOP_Connection_Handler.h @@ -117,6 +117,7 @@ protected: */ // void handle_close_i (void); virtual int release_os_resources (void); + virtual int handle_write_ready (const ACE_Time_Value *timeout); //@} private: diff --git a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp index 45d8f81c236..2f5a6b4c0d6 100644 --- a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp @@ -266,6 +266,12 @@ TAO_SHMIOP_Connection_Handler::add_transport_to_cache (void) return cache.cache_transport (&prop, this->transport ()); } +int +TAO_SHMIOP_Connection_Handler::handle_write_ready (const ACE_Time_Value *t) +{ + return ACE::handle_write_ready (this->peer ().get_handle (), t); +} + TAO_END_VERSIONED_NAMESPACE_DECL #endif /*(TAO_HAS_SHMIOP) && (TAO_HAS_SHMIOP != 0) */ diff --git a/TAO/tao/Strategies/SHMIOP_Connection_Handler.h b/TAO/tao/Strategies/SHMIOP_Connection_Handler.h index ce3d080d4b0..0dc238ae6b2 100644 --- a/TAO/tao/Strategies/SHMIOP_Connection_Handler.h +++ b/TAO/tao/Strategies/SHMIOP_Connection_Handler.h @@ -93,6 +93,7 @@ protected: * @name TAO_Connection Handler overloads */ virtual int release_os_resources (void); + virtual int handle_write_ready (const ACE_Time_Value *timeout); //@} private: diff --git a/TAO/tao/Strategies/UIOP_Connection_Handler.cpp b/TAO/tao/Strategies/UIOP_Connection_Handler.cpp index 8364a47784f..a52abb6c64b 100644 --- a/TAO/tao/Strategies/UIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/UIOP_Connection_Handler.cpp @@ -238,6 +238,12 @@ TAO_UIOP_Connection_Handler::add_transport_to_cache (void) return cache.cache_transport (&prop, this->transport ()); } +int +TAO_UIOP_Connection_Handler::handle_write_ready (const ACE_Time_Value *t) +{ + return ACE::handle_write_ready (this->peer ().get_handle (), t); +} + TAO_END_VERSIONED_NAMESPACE_DECL #endif /*TAO_HAS_UIOP == 1*/ diff --git a/TAO/tao/Strategies/UIOP_Connection_Handler.h b/TAO/tao/Strategies/UIOP_Connection_Handler.h index 6b40184b3e2..8ab218fd69b 100644 --- a/TAO/tao/Strategies/UIOP_Connection_Handler.h +++ b/TAO/tao/Strategies/UIOP_Connection_Handler.h @@ -90,6 +90,7 @@ protected: * @name TAO_Connection Handler overloads */ virtual int release_os_resources (void); + virtual int handle_write_ready (const ACE_Time_Value *timeout); //@} }; diff --git a/TAO/tao/Transport.cpp b/TAO/tao/Transport.cpp index 9494364a241..e2102707cb1 100644 --- a/TAO/tao/Transport.cpp +++ b/TAO/tao/Transport.cpp @@ -521,7 +521,7 @@ TAO_Transport::update_transport (void) * Methods called and used in the output path of the ORB. * */ -int +TAO_Transport::Drain_Result TAO_Transport::handle_output (TAO::Transport::Drain_Constraints const & dc) { if (TAO_debug_level > 3) @@ -538,7 +538,7 @@ TAO_Transport::handle_output (TAO::Transport::Drain_Constraints const & dc) // The flushing strategy (potentially via the Reactor) wants to send // more data, first check if there is a current message that needs // more sending... - int const retval = this->drain_queue (dc); + Drain_Result const retval = this->drain_queue (dc); if (TAO_debug_level > 3) { @@ -546,7 +546,7 @@ TAO_Transport::handle_output (TAO::Transport::Drain_Constraints const & dc) ACE_TEXT ("TAO (%P|%t) - Transport[%d]::handle_output, ") ACE_TEXT ("drain_queue returns %d/%d\n"), this->id (), - retval, ACE_ERRNO_GET)); + static_cast<int> (retval.dre_), ACE_ERRNO_GET)); } // Any errors are returned directly to the Reactor @@ -592,14 +592,14 @@ TAO_Transport::send_message_block_chain_i (const ACE_Message_Block *mb, synch_message.push_back (this->head_, this->tail_); - int const n = this->drain_queue_i (dc); + Drain_Result const n = this->drain_queue_i (dc); - if (n == -1) + if (n == DR_ERROR) { synch_message.remove_from_list (this->head_, this->tail_); return -1; // Error while sending... } - else if (n == 1) + else if (n == DR_QUEUE_EMPTY) { bytes_transferred = total_length; return 1; // Empty queue, message was sent.. @@ -780,14 +780,14 @@ TAO_Transport::send_synch_message_helper_i (TAO_Synch_Queued_Message &synch_mess TAO::Transport::Drain_Constraints dc( max_wait_time, this->using_blocking_io_for_synch_messages()); - int const n = this->drain_queue_i (dc); + Drain_Result const n = this->drain_queue_i (dc); - if (n == -1) + if (n == DR_ERROR) { synch_message.remove_from_list (this->head_, this->tail_); return -1; // Error while sending... } - else if (n == 1) + else if (n == DR_QUEUE_EMPTY) { return 1; // Empty queue, message was sent.. } @@ -911,13 +911,13 @@ TAO_Transport::handle_timeout (const ACE_Time_Value & /* current_time */, return 0; } -int +TAO_Transport::Drain_Result TAO_Transport::drain_queue (TAO::Transport::Drain_Constraints const & dc) { - ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, -1); - int const retval = this->drain_queue_i (dc); + ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, DR_ERROR); + Drain_Result const retval = this->drain_queue_i (dc); - if (retval == 1) + if (retval == DR_QUEUE_EMPTY) { // ... there is no current message or it was completely // sent, cancel output... @@ -926,13 +926,13 @@ TAO_Transport::drain_queue (TAO::Transport::Drain_Constraints const & dc) flushing_strategy->cancel_output (this); - return 0; + return DR_OK; } return retval; } -int +TAO_Transport::Drain_Result TAO_Transport::drain_queue_helper (int &iovcnt, iovec iov[], TAO::Transport::Drain_Constraints const & dc) { @@ -973,7 +973,7 @@ TAO_Transport::drain_queue_helper (int &iovcnt, iovec iov[], ACE_TEXT ("send() returns 0\n"), this->id ())); } - return -1; + return DR_ERROR; } else if (retval == -1) { @@ -987,10 +987,10 @@ TAO_Transport::drain_queue_helper (int &iovcnt, iovec iov[], if (errno == EWOULDBLOCK || errno == EAGAIN) { - return 0; + return DR_WOULDBLOCK; } - return -1; + return DR_ERROR; } // ... now we need to update the queue, removing elements @@ -1013,10 +1013,11 @@ TAO_Transport::drain_queue_helper (int &iovcnt, iovec iov[], this->id(), byte_count, (this->head_ == 0))); } - return 1; + return DR_QUEUE_EMPTY; + // drain_queue_i will check if the queue is actually empty } -int +TAO_Transport::Drain_Result TAO_Transport::drain_queue_i (TAO::Transport::Drain_Constraints const & dc) { // This is the vector used to send data, it must be declared outside @@ -1068,23 +1069,24 @@ TAO_Transport::drain_queue_i (TAO::Transport::Drain_Constraints const & dc) // IOV_MAX elements ... if (iovcnt == ACE_IOV_MAX) { - int const retval = this->drain_queue_helper (iovcnt, iov, dc); - - now = ACE_High_Res_Timer::gettimeofday_hr (); + Drain_Result const retval = + this->drain_queue_helper (iovcnt, iov, dc); if (TAO_debug_level > 4) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - Transport[%d]::drain_queue_i, ") ACE_TEXT ("helper retval = %d\n"), - this->id (), retval)); + this->id (), static_cast<int> (retval.dre_))); } - if (retval != 1) + if (retval != DR_QUEUE_EMPTY) { return retval; } + now = ACE_High_Res_Timer::gettimeofday_hr (); + i = this->head_; continue; } @@ -1095,17 +1097,17 @@ TAO_Transport::drain_queue_i (TAO::Transport::Drain_Constraints const & dc) if (iovcnt != 0) { - int const retval = this->drain_queue_helper (iovcnt, iov, dc); + Drain_Result const retval = this->drain_queue_helper (iovcnt, iov, dc); if (TAO_debug_level > 4) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - Transport[%d]::drain_queue_i, ") ACE_TEXT ("helper retval = %d\n"), - this->id (), retval)); + this->id (), static_cast<int> (retval.dre_))); } - if (retval != 1) + if (retval != DR_QUEUE_EMPTY) { return retval; } @@ -1121,10 +1123,10 @@ TAO_Transport::drain_queue_i (TAO::Transport::Drain_Constraints const & dc) this->reset_flush_timer (); } - return 1; + return DR_QUEUE_EMPTY; } - return 0; + return DR_OK; } void diff --git a/TAO/tao/Transport.h b/TAO/tao/Transport.h index 40ab7fac84e..0c8d325d82c 100644 --- a/TAO/tao/Transport.h +++ b/TAO/tao/Transport.h @@ -364,8 +364,35 @@ public: */ TAO_Wait_Strategy *wait_strategy (void) const; + enum Drain_Result_Enum + { + DR_ERROR = -1, + DR_OK = 0, + DR_QUEUE_EMPTY = 1, // used internally, not returned from drain_queue() + DR_WOULDBLOCK = 2 + }; + + /// The handle_output and drain_queue* functions return objects of this + /// struct instead of the enum value directly so the compiler will catch + /// any uses that assign the return value to an int. + struct Drain_Result + { + Drain_Result (Drain_Result_Enum dre) : dre_(dre) {} + Drain_Result_Enum dre_; + + bool operator== (Drain_Result rhs) const + { + return this->dre_ == rhs.dre_; + } + + bool operator!= (Drain_Result rhs) const + { + return this->dre_ != rhs.dre_; + } + }; + /// Callback method to reactively drain the outgoing data queue - int handle_output (TAO::Transport::Drain_Constraints const & c); + Drain_Result handle_output (TAO::Transport::Drain_Constraints const & c); /// Get the bidirectional flag int bidirectional_flag (void) const; @@ -895,14 +922,11 @@ private: /** * As the outgoing data is drained this method is invoked to send as * much of the current message as possible. - * - * Returns 0 if there is more data to send, -1 if there was an error - * and 1 if the message was completely sent. */ - int drain_queue (TAO::Transport::Drain_Constraints const & dc); + Drain_Result drain_queue (TAO::Transport::Drain_Constraints const & dc); /// Implement drain_queue() assuming the lock is held - int drain_queue_i (TAO::Transport::Drain_Constraints const & dc); + Drain_Result drain_queue_i (TAO::Transport::Drain_Constraints const & dc); /// Check if there are messages pending in the queue /** @@ -914,7 +938,7 @@ private: bool queue_is_empty_i (void) const; /// A helper routine used in drain_queue_i() - int drain_queue_helper (int &iovcnt, iovec iov[], + Drain_Result drain_queue_helper (int &iovcnt, iovec iov[], TAO::Transport::Drain_Constraints const & dc); /// These classes need privileged access to: |