diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-01-28 00:04:21 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-01-28 00:04:21 +0000 |
commit | 244f59e2ddce11bf77b87a3c206954952fceefa1 (patch) | |
tree | 64c4055e0b778cc0e23b40c0d7185e802d863b7e | |
parent | e839c96e78c4442bcf5ccfc09fde2e24bf8e7192 (diff) | |
download | ATCD-244f59e2ddce11bf77b87a3c206954952fceefa1.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/tao/SHMIOP_Transport.cpp | 37 | ||||
-rw-r--r-- | TAO/tao/default_resource.cpp | 39 | ||||
-rw-r--r-- | ace/MEM_IO.h | 12 | ||||
-rw-r--r-- | ace/MEM_IO.i | 59 |
4 files changed, 108 insertions, 39 deletions
diff --git a/TAO/tao/SHMIOP_Transport.cpp b/TAO/tao/SHMIOP_Transport.cpp index 520e1775fbe..198fff4e5e4 100644 --- a/TAO/tao/SHMIOP_Transport.cpp +++ b/TAO/tao/SHMIOP_Transport.cpp @@ -335,10 +335,29 @@ TAO_SHMIOP_Transport::send (const ACE_Message_Block *message_block, const ACE_Time_Value *max_wait_time) { TAO_FUNCTION_PP_TIMEPROBE (TAO_SHMIOP_TRANSPORT_SEND_START); + ssize_t n = 0; + ssize_t len = 0; + ssize_t nbytes = 0; - return ACE::send_n (this->handle (), - message_block, - max_wait_time); + while (message_block != 0) + { + len = message_block->length (); + if (len > 0) + { + n = this->handler_->peer ().send (message_block->rd_ptr (), + len, + max_wait_time); + if (n <= 0) + return n; + } + + if (message_block->cont ()) + message_block = message_block->cont (); + else + message_block = message_block->next (); + } + + return nbytes; } ssize_t @@ -348,9 +367,9 @@ TAO_SHMIOP_Transport::send (const u_char *buf, { TAO_FUNCTION_PP_TIMEPROBE (TAO_SHMIOP_TRANSPORT_SEND_START); - return this->handler_->peer ().send_n (buf, - len, - max_wait_time); + return this->handler_->peer ().send (buf, + len, + max_wait_time); } ssize_t @@ -360,9 +379,9 @@ TAO_SHMIOP_Transport::recv (char *buf, { TAO_FUNCTION_PP_TIMEPROBE (TAO_SHMIOP_TRANSPORT_RECEIVE_START); - return this->handler_->peer ().recv_n (buf, - len, - max_wait_time); + return this->handler_->peer ().recv (buf, + len, + max_wait_time); } // Default action to be taken for send request. diff --git a/TAO/tao/default_resource.cpp b/TAO/tao/default_resource.cpp index 511b7a366ee..3828e5499c5 100644 --- a/TAO/tao/default_resource.cpp +++ b/TAO/tao/default_resource.cpp @@ -421,6 +421,45 @@ TAO_Default_Resource_Factory::init_protocol_factories (void) "TAO (%P|%t) Loaded default protocol <UIOP_Factory>\n")); } #endif /* TAO_HAS_UIOP */ + +#if defined (TAO_HAS_SHMIOP) + protocol_factory = + ACE_Dynamic_Service<TAO_Protocol_Factory>::instance ("SHMIOP_Factory"); + + if (protocol_factory == 0) + { + if (TAO_orbdebug) + ACE_ERROR ((LM_WARNING, + "(%P|%t) WARNING - No %s found in Service Repository." + " Using default instance.\n", + "SHMIOP Protocol Factory")); + + ACE_NEW_RETURN (protocol_factory, + TAO_SHMIOP_Protocol_Factory, + -1); + } + + ACE_NEW_RETURN (item, TAO_Protocol_Item ("SHMIOP_Factory"), -1); + item->factory (protocol_factory); + + if (this->protocol_factories_.insert (item) == -1) + { + delete item; + delete protocol_factory; + + ACE_ERROR_RETURN ((LM_ERROR, + "TAO (%P|%t) Unable to add " + "<%s> to protocol factory set.\n", + item->protocol_name ().c_str ()), + -1); + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "TAO (%P|%t) Loaded default protocol <SHMIOP_Factory>\n")); + } +#endif /* TAO_HAS_SHMIOP */ return 0; } diff --git a/ace/MEM_IO.h b/ace/MEM_IO.h index 98c5dcff628..af99ea3f2fd 100644 --- a/ace/MEM_IO.h +++ b/ace/MEM_IO.h @@ -59,7 +59,7 @@ public: size_t n) ; // Recv an <n> byte buffer from the shm_malloc_ thru connected socket. - ssize_t fetch_recv_buf (int flags); + ssize_t fetch_recv_buf (int flags, ACE_Time_Value *timeout = 0); // @@ Please fill in here. /* @@ -83,11 +83,12 @@ public: ssize_t recv (iovec *io_vec, const ACE_Time_Value *timeout = 0); // Same as above. Deprecated. + */ ssize_t send (const void *buf, size_t n, int flags, - const ACE_Time_Value *timeout) const; + const ACE_Time_Value *timeout); // Wait to to <timeout> amount of time to send up to <n> bytes into // <buf> from <handle> (uses the <send> call). If <send> times out // a -1 is returned with <errno == ETIME>. If it succeeds the @@ -96,7 +97,7 @@ public: ssize_t recv (void *buf, size_t n, int flags, - const ACE_Time_Value *timeout) const; + const ACE_Time_Value *timeout); // Wait up to <timeout> amount of time to receive up to <n> bytes // into <buf> from <handle> (uses the <recv> call). If <recv> times // out a -1 is returned with <errno == ETIME>. If it succeeds the @@ -104,7 +105,7 @@ public: ssize_t send (const void *buf, size_t n, - const ACE_Time_Value *timeout) const; + const ACE_Time_Value *timeout); // Wait to to <timeout> amount of time to send up to <n> bytes into // <buf> from <handle> (uses the <send> call). If <send> times out // a -1 is returned with <errno == ETIME>. If it succeeds the @@ -112,12 +113,13 @@ public: ssize_t recv (void *buf, size_t n, - const ACE_Time_Value *timeout) const; + const ACE_Time_Value *timeout); // Wait up to <timeout> amount of time to receive up to <n> bytes // into <buf> from <handle> (uses the <recv> call). If <recv> times // out a -1 is returned with <errno == ETIME>. If it succeeds the // number of bytes received is returned. + /* ssize_t send (size_t n, ...) const; // Send <n> varargs messages to the connected socket. diff --git a/ace/MEM_IO.i b/ace/MEM_IO.i index 5ab42f3c168..54ef8803561 100644 --- a/ace/MEM_IO.i +++ b/ace/MEM_IO.i @@ -23,18 +23,7 @@ ASYS_INLINE ssize_t ACE_MEM_IO::send (const void *buf, size_t n, int flags) { ACE_TRACE ("ACE_MEM_IO::send"); - void *sbuf = this->acquire_buffer (n); - if (sbuf == 0) - return -1; // Memory buffer not initialized. - ACE_OS::memcpy (sbuf, buf, n); - off_t offset = this->set_buf_len (sbuf, n); // <set_buf_len> also calculate - // the offset. - - // Send the offset value over the socket. - return ACE_OS::send (this->get_handle (), - (const char *) &offset, - sizeof (offset), - flags); + return this->send (buf, n, flags, 0); } // Recv an n byte message from the connected socket. @@ -89,7 +78,7 @@ ACE_MEM_IO::recv (void *buf, size_t n) } ASYS_INLINE ssize_t -ACE_MEM_IO::fetch_recv_buf (int flag) +ACE_MEM_IO::fetch_recv_buf (int flag, ACE_Time_Value *timeout) { ACE_TRACE ("ACE_MEM_IO::fetch_recv_buf"); @@ -98,14 +87,15 @@ ACE_MEM_IO::fetch_recv_buf (int flag) // We have done using the previous buffer, return it to malloc. if (this->recv_buffer_ != 0) - this->shm_malloc_->free (this->recv_buffer_); + this->release_buffer (this->recv_buffer_); this->cur_offset_ = 0; off_t new_offset = 0; - int retv = ACE_OS::recv (this->get_handle (), - (char *) &new_offset, - sizeof (off_t), - flag); + int retv = ACE::recv (this->get_handle (), + (char *) &new_offset, + sizeof (off_t), + flag, + timeout); if (retv != sizeof (off_t)) { @@ -163,21 +153,41 @@ ACE_MEM_IO::recv (void *buf, size_t n, return ACE_OS::read (this->get_handle (), (char *) buf, n, overlapped); } +*/ ASYS_INLINE ssize_t ACE_MEM_IO::send (const void *buf, size_t len, int flags, - const ACE_Time_Value *timeout) const + const ACE_Time_Value *timeout) { ACE_TRACE ("ACE_MEM_IO::send"); - return ACE::send (this->get_handle (), buf, len, flags, timeout); + void *sbuf = this->acquire_buffer (len); + if (sbuf == 0) + return -1; // Memory buffer not initialized. + ACE_OS::memcpy (sbuf, buf, len); + off_t offset = this->set_buf_len (sbuf, len); // <set_buf_len> also calculate + // the offset. + + // Send the offset value over the socket. + if (ACE::send (this->get_handle (), + (const char *) &offset, + sizeof (offset), + flags, + timeout) != sizeof (offset)) + { + // unsucessful send, release the memory in the shared-memory. + this->release_buffer (sbuf); + + return -1; + } + return len; } ASYS_INLINE ssize_t ACE_MEM_IO::recv (void *buf, size_t len, - const ACE_Time_Value *timeout) const + const ACE_Time_Value *timeout) { ACE_TRACE ("ACE_MEM_IO::recv"); return ACE::recv (this->get_handle (), buf, len, timeout); @@ -186,19 +196,18 @@ ACE_MEM_IO::recv (void *buf, ASYS_INLINE ssize_t ACE_MEM_IO::send (const void *buf, size_t len, - const ACE_Time_Value *timeout) const + const ACE_Time_Value *timeout) { ACE_TRACE ("ACE_MEM_IO::send"); - return ACE::send (this->get_handle (), buf, len, timeout); + return this->send (buf, len, 0, timeout); } ASYS_INLINE ssize_t ACE_MEM_IO::recv (void *buf, size_t len, int flags, - const ACE_Time_Value *timeout) const + const ACE_Time_Value *timeout) { ACE_TRACE ("ACE_MEM_IO::recv"); return ACE::recv (this->get_handle (), buf, len, flags, timeout); } -*/ |