diff options
author | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
commit | 26b5e033ffde3d161382fc9addbfa99738379641 (patch) | |
tree | a344f369ca32945f787a02dee35c3dbe342bed7e /dep/ACE_wrappers/ace/Pipe.cpp | |
parent | f21f47005dcb6b76e1abc9f35fbcd03eed191bff (diff) |
*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget
--HG--
branch : trunk
Diffstat (limited to 'dep/ACE_wrappers/ace/Pipe.cpp')
-rw-r--r-- | dep/ACE_wrappers/ace/Pipe.cpp | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/dep/ACE_wrappers/ace/Pipe.cpp b/dep/ACE_wrappers/ace/Pipe.cpp index 717f72e52ea..95075772f0e 100644 --- a/dep/ACE_wrappers/ace/Pipe.cpp +++ b/dep/ACE_wrappers/ace/Pipe.cpp @@ -1,5 +1,4 @@ // $Id: Pipe.cpp 80826 2008-03-04 14:51:23Z wotte $ - #include "ace/Pipe.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Connector.h" @@ -7,21 +6,15 @@ #include "ace/OS_NS_sys_socket.h" #include "ace/OS_Memory.h" #include "ace/Truncate.h" - #if defined (ACE_HAS_STREAM_PIPES) || defined (__QNX__) # include "ace/OS_NS_unistd.h" #endif // ACE_HAS_STREAM_PIPES || __QNX__ - #include "ace/os_include/netinet/os_tcp.h" - #if !defined (__ACE_INLINE__) #include "ace/Pipe.inl" #endif /* __ACE_INLINE__ */ - ACE_RCSID(ace, Pipe, "$Id: Pipe.cpp 80826 2008-03-04 14:51:23Z wotte $") - ACE_BEGIN_VERSIONED_NAMESPACE_DECL - void ACE_Pipe::dump (void) const { @@ -34,12 +27,10 @@ ACE_Pipe::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); #endif /* ACE_HAS_DUMP */ } - int ACE_Pipe::open (int buffer_size) { ACE_TRACE ("ACE_Pipe::open"); - #if defined (ACE_LACKS_SOCKETPAIR) || defined (__Lynx__) ACE_INET_Addr my_addr; ACE_SOCK_Acceptor acceptor; @@ -52,7 +43,6 @@ ACE_Pipe::open (int buffer_size) # else ACE_Addr local_any = ACE_Addr::sap_any; # endif /* ACE_WIN32 */ - // Bind listener to any port and then find out what the port was. if (acceptor.open (local_any) == -1 || acceptor.get_local_addr (my_addr) == -1) @@ -61,7 +51,6 @@ ACE_Pipe::open (int buffer_size) { ACE_INET_Addr sv_addr (my_addr.get_port_number (), ACE_LOCALHOST); - // Establish a connection within the same process. if (connector.connect (writer, sv_addr) == -1) result = -1; @@ -71,22 +60,17 @@ ACE_Pipe::open (int buffer_size) result = -1; } } - // Close down the acceptor endpoint since we don't need it anymore. acceptor.close (); if (result == -1) return -1; - this->handles_[0] = reader.get_handle (); this->handles_[1] = writer.get_handle (); - # if !defined (ACE_LACKS_TCP_NODELAY) int one = 1; - // Make sure that the TCP stack doesn't try to buffer small writes. // Since this communication is purely local to the host it doesn't // affect network performance. - if (writer.set_option (ACE_IPPROTO_TCP, TCP_NODELAY, &one, @@ -96,7 +80,6 @@ ACE_Pipe::open (int buffer_size) return -1; } # endif /* ! ACE_LACKS_TCP_NODELAY */ - # if defined (ACE_LACKS_SOCKET_BUFSIZ) ACE_UNUSED_ARG (buffer_size); # else /* ! ACE_LACKS_SOCKET_BUFSIZ */ @@ -119,7 +102,6 @@ ACE_Pipe::open (int buffer_size) return -1; } # endif /* ! ACE_LACKS_SOCKET_BUFSIZ */ - #elif defined (ACE_HAS_STREAM_PIPES) || defined (__QNX__) ACE_UNUSED_ARG (buffer_size); if (ACE_OS::pipe (this->handles_) == -1) @@ -127,10 +109,8 @@ ACE_Pipe::open (int buffer_size) ACE_TEXT ("%p\n"), ACE_TEXT ("pipe")), -1); - #if !defined(__QNX__) int arg = RMSGN; - // Enable "msg no discard" mode, which ensures that record // boundaries are maintained when messages are sent and received. if (ACE_OS::ioctl (this->handles_[0], @@ -146,7 +126,6 @@ ACE_Pipe::open (int buffer_size) ACE_TEXT ("ioctl")), -1); } #endif /* __QNX__ */ - #else /* ! ACE_LACKS_SOCKETPAIR && ! ACE_HAS_STREAM_PIPES */ if (ACE_OS::socketpair (AF_UNIX, SOCK_STREAM, @@ -198,15 +177,12 @@ ACE_Pipe::open (int buffer_size) #endif /* ! ACE_LACKS_SOCKETPAIR && ! ACE_HAS_STREAM_PIPES */ // Point both the read and write HANDLES to the appropriate socket // HANDLEs. - return 0; } - int ACE_Pipe::open (ACE_HANDLE handles[2]) { ACE_TRACE ("ACE_Pipe::open"); - if (this->open () == -1) return -1; else @@ -216,26 +192,20 @@ ACE_Pipe::open (ACE_HANDLE handles[2]) return 0; } } - // Do nothing... - ACE_Pipe::ACE_Pipe (void) { ACE_TRACE ("ACE_Pipe::ACE_Pipe"); - this->handles_[0] = ACE_INVALID_HANDLE; this->handles_[1] = ACE_INVALID_HANDLE; } - ACE_Pipe::ACE_Pipe (ACE_HANDLE handles[2]) { ACE_TRACE ("ACE_Pipe::ACE_Pipe"); - if (this->open (handles) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_Pipe::ACE_Pipe"))); } - ACE_Pipe::ACE_Pipe (ACE_HANDLE read, ACE_HANDLE write) { @@ -243,34 +213,26 @@ ACE_Pipe::ACE_Pipe (ACE_HANDLE read, this->handles_[0] = read; this->handles_[1] = write; } - int ACE_Pipe::close (void) { ACE_TRACE ("ACE_Pipe::close"); - int result = 0; - // Note that the following will work even if we aren't closing down // sockets because <ACE_OS::closesocket> will just call <::close> in // that case! - if (this->handles_[0] != ACE_INVALID_HANDLE) result = ACE_OS::closesocket (this->handles_[0]); this->handles_[0] = ACE_INVALID_HANDLE; - if (this->handles_[1] != ACE_INVALID_HANDLE) result |= ACE_OS::closesocket (this->handles_[1]); this->handles_[1] = ACE_INVALID_HANDLE; - return result; } - // Send N char *ptrs and int lengths. Note that the char *'s precede // the ints (basically, an varargs version of writev). The count N is // the *total* number of trailing arguments, *not* a couple of the // number of tuple pairs! - ssize_t ACE_Pipe::send (size_t n, ...) const { @@ -285,15 +247,12 @@ ACE_Pipe::send (size_t n, ...) const iovec[total_tuples], -1); #endif /* !defined (ACE_HAS_ALLOCA) */ - va_start (argp, n); - for (int i = 0; i < total_tuples; ++i) { iovp[i].iov_base = va_arg (argp, char *); iovp[i].iov_len = va_arg (argp, int); } - #if defined (ACE_WIN32) ssize_t result = ACE::sendv (this->write_handle (), iovp, @@ -303,20 +262,17 @@ ACE_Pipe::send (size_t n, ...) const iovp, total_tuples); #endif /* ACE_WIN32 */ - #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; } - // This is basically an interface to ACE_OS::readv, that doesn't use // the struct iovec explicitly. The ... can be passed as an arbitrary // number of (char *ptr, int len) tuples. However, the count N is the // *total* number of trailing arguments, *not* a couple of the number // of tuple pairs! - ssize_t ACE_Pipe::recv (size_t n, ...) const { @@ -331,15 +287,12 @@ ACE_Pipe::recv (size_t n, ...) const iovec[total_tuples], -1); #endif /* !defined (ACE_HAS_ALLOCA) */ - va_start (argp, n); - for (int i = 0; i < total_tuples; ++i) { iovp[i].iov_base = va_arg (argp, char *); iovp[i].iov_len = va_arg (argp, int); } - #if defined (ACE_WIN32) ssize_t const result = ACE::recvv (this->read_handle (), iovp, @@ -349,13 +302,11 @@ ACE_Pipe::recv (size_t n, ...) const iovp, total_tuples); #endif /* ACE_WIN32 */ - #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; } - ACE_END_VERSIONED_NAMESPACE_DECL |