diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-04-24 08:02:58 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-04-24 08:02:58 +0000 |
commit | ffb827a2938294145c0c74d7e06d837236d29694 (patch) | |
tree | 8c0bc2f7aa508472a4fd98dfca9d6afd60130f52 /TAO/examples/PluggableUDP/DIOP | |
parent | d01a55ccd330806cac88d2e978e6d3d59a844bef (diff) | |
download | ATCD-ffb827a2938294145c0c74d7e06d837236d29694.tar.gz |
ChangeLogTag:Tue Apr 24 00:21:54 2001 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'TAO/examples/PluggableUDP/DIOP')
-rw-r--r-- | TAO/examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp | 36 | ||||
-rw-r--r-- | TAO/examples/PluggableUDP/DIOP/DIOP_Transport.cpp | 180 | ||||
-rw-r--r-- | TAO/examples/PluggableUDP/DIOP/DIOP_Transport.h | 7 |
3 files changed, 22 insertions, 201 deletions
diff --git a/TAO/examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp b/TAO/examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp index 1582bccf625..8afe2b82c74 100644 --- a/TAO/examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp +++ b/TAO/examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp @@ -59,23 +59,7 @@ TAO_DIOP_Connection_Handler::TAO_DIOP_Connection_Handler (TAO_ORB_Core *orb_core TAO_DIOP_Connection_Handler::~TAO_DIOP_Connection_Handler (void) { - if (this->transport () != 0) { - // If the socket has not already been closed. - if (this->get_handle () != ACE_INVALID_HANDLE) - { - // Cannot deal with errors, and therefore they are ignored. - this->transport ()->send_buffered_messages (); - } - else - { - // Dequeue messages and delete message blocks. - this->transport ()->dequeue_all (); - } - } - // @@ Frank: Added from DIOP_Connect.cpp - this->handle_cleanup (); - - udp_socket_.close (); + this->udp_socket_.close (); } // DIOP Additions - Begin @@ -247,9 +231,6 @@ TAO_DIOP_Connection_Handler::handle_close (ACE_HANDLE handle, // Close the handle.. if (this->get_handle () != ACE_INVALID_HANDLE) { - // Send the buffered messages first - this->transport ()->send_buffered_messages (); - // Purge the entry too this->transport ()->mark_invalid (); @@ -278,18 +259,11 @@ int TAO_DIOP_Connection_Handler::handle_timeout (const ACE_Time_Value &, const void *) { - // This method is called when buffering timer expires. - // - ACE_Time_Value *max_wait_time = 0; - - TAO_Stub *stub = 0; - int has_timeout; - this->orb_core ()->call_timeout_hook (stub, - has_timeout, - *max_wait_time); - // Cannot deal with errors, and therefore they are ignored. - this->transport ()->send_buffered_messages (max_wait_time); + if (this->transport ()->handle_output () == -1) + { + return -1; + } return 0; } diff --git a/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.cpp b/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.cpp index d8fc10372d0..bed3fa5b098 100644 --- a/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.cpp +++ b/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.cpp @@ -1,6 +1,10 @@ // This may look like C, but it's really -*- C++ -*- // $Id$ +#include "DIOP_Transport.h" +#include "DIOP_Connection_Handler.h" +#include "DIOP_Acceptor.h" +#include "DIOP_Profile.h" #include "tao/Acceptor_Registry.h" #include "tao/operation_details.h" #include "tao/Timeprobe.h" @@ -14,12 +18,6 @@ #include "tao/GIOP_Message_Base.h" #include "tao/GIOP_Message_Lite.h" - -#include "DIOP_Transport.h" -#include "DIOP_Connection_Handler.h" -#include "DIOP_Acceptor.h" -#include "DIOP_Profile.h" - #if !defined (__ACE_INLINE__) # include "DIOP_Transport.i" #endif /* ! __ACE_INLINE__ */ @@ -69,155 +67,17 @@ TAO_DIOP_Transport::messaging_object (void) return this->messaging_object_; } - ssize_t -TAO_DIOP_Transport::send_i (const ACE_Message_Block *message_block, - const ACE_Time_Value * /*max_wait_time*/, - size_t *bt) +TAO_DIOP_Transport::send_i (iovec *iov, int iovcnt, + size_t &bytes_transferred, + const ACE_Time_Value *max_wait_time) { - const ACE_INET_Addr &addr = this->connection_handler_->addr (); - - /*size_t temp = 0; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - bytes_transferred = 0;*/ - ssize_t bytes_transferred = 0; - if (bt) - { - bytes_transferred = *bt; - } - - char stack_buffer[ACE_MAX_DGRAM_SIZE]; - size_t stack_offset=0; - size_t message_length=0; - - iovec iov[IOV_MAX]; - int iovcnt = 0; - - while (message_block != 0) - { - // Our current message block chain. - const ACE_Message_Block *current_message_block = message_block; - - while (current_message_block != 0) - { - size_t current_message_block_length = - current_message_block->length (); - - message_length += current_message_block_length; - - if(message_length > ACE_MAX_DGRAM_SIZE) - { - // This is an error as we do not send more. - // Silently drop the message but log an error. - - // Pluggable_Messaging::transport_message only - // cares if it gets -1 or 0 so we can return a - // partial length and it will think all has gone - // well. - - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("\n\nTAO (%P|%t) ") - ACE_TEXT ("DIOP_Transport::send ") - ACE_TEXT ("Message length %d exceeds ACE_MAX_DGRAM_SIZE=%d\n"), - message_length, - ACE_MAX_DGRAM_SIZE)); - } - - return 1; // Pretend it is o.k. - // This is a problem in the message - // catalogue. - } - - // Check if this block has any data to be sent. - if (current_message_block_length > 0) - { - if(iovcnt < (IOV_MAX-1)) - { - // Collect the data in the iovec. - iov[iovcnt].iov_base = current_message_block->rd_ptr (); - iov[iovcnt].iov_len = current_message_block_length; - - // Increment iovec counter. - iovcnt++; - - // The buffer is full make a OS call. @@ TODO find a way to - // find IOV_MAX for platforms that do not define it rather - // than simply setting IOV_MAX to some arbitrary value such - // as 16. - } - else - { - // @@ John Mackenzie. If we reach IOVMAX-1 we need to pack - // the remanining blocks into the last available buffer. - - ACE_OS::memcpy(stack_buffer+stack_offset, - current_message_block->rd_ptr (), - current_message_block_length); - stack_offset += current_message_block_length; - - iovcnt = IOV_MAX; // We just stay with the last buffer. - iov[iovcnt-1].iov_base = stack_buffer; - iov[iovcnt-1].iov_len = stack_offset; - } - } - - // Select the next message block in the chain. - current_message_block = current_message_block->cont (); - } - - // Selection of the next message block chain. - message_block = message_block->next (); - } - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("\n\nTAO (%P|%t) ") - ACE_TEXT ("iovcnt is %d \n."),iovcnt)); - } - - // Send the buffers. + ssize_t retval = this->connection_handler_->peer ().sendv (iov, iovcnt, + max_wait_time); + if (retval > 0) + bytes_transferred = retval; - if (iovcnt != 0) - { - bytes_transferred = - this->connection_handler_->dgram ().send (iov, - iovcnt, - addr); - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - "TAO_DIOP_Transport::send_i: sent %d bytes to %s:%d\n", - bytes_transferred, - addr.get_host_name (), - addr.get_port_number ())); - } - - // Errors. - // @@ John Mackenzie. We cannot propogate errors up in DIOP - // as it will cause transport recycle which makes no sense - // Error could be ECONNREFUSED if transport reports ICMP errors. - } - - if (bytes_transferred == -1 || bytes_transferred == 0) - { - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("\n\nTAO (%P|%t) ") - ACE_TEXT ("DIOP_Transport::send") - ACE_TEXT (" %p\n\n"), - ACE_TEXT ("Error returned from transport:"))); - } - return 1; // Fake a good return. - } - - // Return total bytes transferred. - return bytes_transferred; + return retval; } ssize_t @@ -288,7 +148,7 @@ int TAO_DIOP_Transport::register_handler_i (void) { // @@ Michael: - // + // // We do never register register the handler with the reactor // as we never need to be informed about any incoming data, // assuming we only use one-ways. @@ -352,7 +212,7 @@ TAO_DIOP_Transport::send_message (TAO_OutputCDR &stream, // versions seem to need it though. Leaving it costs little. // This guarantees to send all data (bytes) or return an error. - ssize_t n = this->send_or_buffer (stub, + ssize_t n = this->send_message_i (stub, twoway, stream.begin (), max_wait_time); @@ -368,17 +228,6 @@ TAO_DIOP_Transport::send_message (TAO_OutputCDR &stream, return -1; } - // EOF. - if (n == 0) - { - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO: (%P|%t|%N|%l) send_message () \n") - ACE_TEXT ("EOF, closing transport %d\n"), - this->id ())); - return -1; - } - return 1; } @@ -675,4 +524,3 @@ TAO_DIOP_Transport::transition_handler_state_i (void) { this->connection_handler_ = 0; } - diff --git a/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.h b/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.h index c4585141dd1..3e4abd9c43e 100644 --- a/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.h +++ b/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.h @@ -72,10 +72,9 @@ protected: virtual TAO_Pluggable_Messaging *messaging_object (void); /// Write the complete Message_Block chain to the connection. - virtual ssize_t send_i (const ACE_Message_Block *mblk, - const ACE_Time_Value *s = 0, - size_t *bytes_transferred = 0); - + virtual ssize_t send_i (iovec *iov, int iovcnt, + size_t &bytes_transferred, + const ACE_Time_Value *max_wait_time); /// Read len bytes from into buf. virtual ssize_t recv_i (char *buf, |