diff options
-rw-r--r-- | ChangeLog-97a | 27 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | ace/DEV_IO.cpp | 14 | ||||
-rw-r--r-- | ace/FILE_IO.cpp | 16 | ||||
-rw-r--r-- | ace/OS.cpp | 75 | ||||
-rw-r--r-- | ace/SOCK_Dgram.cpp | 136 | ||||
-rw-r--r-- | ace/SOCK_Dgram.h | 40 | ||||
-rw-r--r-- | ace/SOCK_Dgram.i | 20 | ||||
-rw-r--r-- | ace/SOCK_IO.cpp | 17 | ||||
-rw-r--r-- | ace/SPIPE_Stream.cpp | 16 | ||||
-rw-r--r-- | ace/config-hpux-10.x-g++.h | 8 | ||||
-rw-r--r-- | apps/JAWS/HTTP_Handler.cpp | 4 | ||||
-rw-r--r-- | apps/JAWS/HTTP_Server.cpp | 6 | ||||
-rw-r--r-- | examples/Logger/Acceptor-server/server_loggerd.cpp | 21 | ||||
-rw-r--r-- | examples/Logger/simple-server/Logging_Acceptor.cpp | 5 | ||||
-rw-r--r-- | examples/Logger/simple-server/Logging_Acceptor.h | 1 | ||||
-rw-r--r-- | examples/Logger/simple-server/Logging_Handler.cpp | 30 | ||||
-rw-r--r-- | examples/Logger/simple-server/server_loggerd.cpp | 13 |
18 files changed, 302 insertions, 149 deletions
diff --git a/ChangeLog-97a b/ChangeLog-97a index 89c0846b4a9..16dbecafd6e 100644 --- a/ChangeLog-97a +++ b/ChangeLog-97a @@ -1,3 +1,30 @@ +Sat Mar 22 12:06:22 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> + + * ace/OS.cpp: Added new thread-safe implementations of writev() + and readv() for platforms that lack these functions. + + * ace/SOCK_Dgram.cpp: Added new implementations of + ACE_SOCK_Dgram::{send,recv} that define methods for + send(iovec[], ...) and recv(iovec[], ...) for systems that + don't have sendmsg() and recvmsg(). Thanks to Alan Cabrera + <Alan_Cabrera@fp.cibc.com> for these fixes. + + * apps/jaws/HTTP_Handler.cpp: Removed some problematic template + specializations that were left over from an earlier version of + JAWS. Thanks to Adam Porter <aporter@cs.umd.edu> for reporting + this. + + * examples/Logger/Acceptor-server/server_loggerd.cpp: Revised the + code to use the new ACE_Svc_Handler logic that checks to ensure + that we don't recurse infinitely in handle_close(). + Thanks to Jean-Marc Strauss <strauss@club-internet.fr> for + reporting this problem. + + * examples/Logger/simple-server/Logging_Handler.cpp + (handle_close): Added a check to make sure we don't end up + recursively calling handle_close(). This will prevent + a segfault. + Sat Mar 22 07:30:49 1997 David L. Levine <levine@cs.wustl.edu> * ace/High_Res_Timer.*: Changed scale factor to convert @@ -488,6 +488,8 @@ Mark Wright <markw@odi.com.au> Michael Newton <michaeln@in.ot.com.au> Kumar Neelakantan <kneelaka@painewebber.com> Scott Halstead <scott.halstead@gs.com> +Jean-Marc Strauss <strauss@club-internet.fr> +Adam Porter <aporter@cs.umd.edu> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson and is now at ObjectSpace. Paul devised the recursive diff --git a/ace/DEV_IO.cpp b/ace/DEV_IO.cpp index afa9a947c04..ce855eb03b7 100644 --- a/ace/DEV_IO.cpp +++ b/ace/DEV_IO.cpp @@ -34,11 +34,10 @@ ACE_DEV_IO::send (size_t n, ...) const ACE_TRACE ("ACE_DEV_IO::send"); va_list argp; size_t total_tuples = n / 2; - ssize_t result; + iovec *iovp; #if defined (ACE_HAS_ALLOCA) - iovec *iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - iovec *iovp; ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -50,7 +49,7 @@ ACE_DEV_IO::send (size_t n, ...) const iovp[i].iov_len = va_arg (argp, int); } - result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -70,11 +69,10 @@ ACE_DEV_IO::recv (size_t n, ...) const ACE_TRACE ("ACE_DEV_IO::recv"); va_list argp; size_t total_tuples = n / 2; - ssize_t result; + iovec *iovp; #if defined (ACE_HAS_ALLOCA) - iovec *iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - iovec *iovp; ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -86,7 +84,7 @@ ACE_DEV_IO::recv (size_t n, ...) const iovp[i].iov_len = va_arg (argp, int); } - result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ diff --git a/ace/FILE_IO.cpp b/ace/FILE_IO.cpp index 6f2c57fe50a..a02e38c656d 100644 --- a/ace/FILE_IO.cpp +++ b/ace/FILE_IO.cpp @@ -34,12 +34,10 @@ ACE_FILE_IO::send (size_t n, ...) const ACE_TRACE ("ACE_FILE_IO::send"); va_list argp; size_t total_tuples = n / 2; - ssize_t result; + iovec *iovp; #if defined (ACE_HAS_ALLOCA) - iovec *iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - iovec *iovp; - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -51,7 +49,7 @@ ACE_FILE_IO::send (size_t n, ...) const iovp[i].iov_len = va_arg (argp, int); } - result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -71,12 +69,10 @@ ACE_FILE_IO::recv (size_t n, ...) const ACE_TRACE ("ACE_FILE_IO::recv"); va_list argp; size_t total_tuples = n / 2; - ssize_t result; + iovec *iovp; #if defined (ACE_HAS_ALLOCA) - iovec *iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - iovec *iovp; - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -88,7 +84,7 @@ ACE_FILE_IO::recv (size_t n, ...) const iovp[i].iov_len = va_arg (argp, int); } - result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ diff --git a/ace/OS.cpp b/ace/OS.cpp index b3d06d77211..1eb715e99a8 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -1987,43 +1987,88 @@ ACE_OS::fork_exec (char *argv[]) #if defined (ACE_NEEDS_WRITEV) -// "Fake" writev for sites without it. Note that this is totally -// broken for multi-threaded applications since the <send_n> calls are -// not atomic... +// "Fake" writev for sites without it. Note that this is thread-safe. extern "C" int -writev (ACE_HANDLE handle, ACE_WRITEV_TYPE *vp, int vpcount) +writev (ACE_HANDLE handle, ACE_WRITEV_TYPE iov[], int n) { // ACE_TRACE ("::writev"); - int count; + size_t length = 0; + size_t i; - for (count = 0; --vpcount >= 0; count += vp->iov_len, vp++) - if (ACE::send_n (handle, vp->iov_base, vp->iov_len) < 0) + // Determine the total length of all the buffers in <iov>. + for (i = 0; i < n; i++) + if (iov[i].iov_len < 0) return -1; + else + length += iov[i].iov_len; - return count; + char *buf; + +#if defined (ACE_HAS_ALLOCA) + buf = (iovec *) alloca (length); +#else + ACE_NEW_RETURN (buf, length, -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + char *ptr = buf; + + for (i = 0; i < n; i++) + { + ACE_OS::memcpy (ptr, iov[i].iov_base, iov[i].iov_len); + ptr += iov[i].iov_len; + } + + ssize_t result = ACE_SOCK_Dgram::send_n (handle, buf, length); +#if !defined (ACE_HAS_ALLOCA) + delete [] buf; +#endif /* !defined (ACE_HAS_ALLOCA) */ + return result; } #endif /* ACE_NEEDS_WRITEV */ #if defined (ACE_NEEDS_READV) -// "Fake" readv for sites without it. Note that this is totally -// broken for multi-threaded applications since the <send_n> calls are -// not atomic... +// "Fake" readv for sites without it. Note that this is thread-safe. extern "C" int readv (ACE_HANDLE handle, struct iovec *vp, int vpcount) { // ACE_TRACE ("::readv"); - int count; + ssize_t length = 0; + size_t i; - for (count = 0; --vpcount >= 0; count += vp->iov_len, vp++) - if (ACE::recv_n (handle, vp->iov_base, vp->iov_len) < 0) + for (i = 0; i < n; i++) + if (iov[i].iov_len < 0) return -1; + else + length += iov[i].iov_len; + +#if defined (ACE_HAS_ALLOCA) + buf = (iovec *) alloca (length); +#else + ACE_NEW_RETURN (buf, length, -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + length = ACE_SOCK_Dgram::recv_n (buf, length); + + if (length != -1) + { + char *ptr = buf; + + for (i = 0; i < n; i++) + { + ACE_OS::memcpy (iov[i].iov_base, ptr, iov[i].iov_len); + ptr += iov[i].iov_len; + } + } - return count; +#if !defined (ACE_HAS_ALLOCA) + delete [] buf; +#endif /* !defined (ACE_HAS_ALLOCA) */ + return length; } #endif /* ACE_NEEDS_READV */ diff --git a/ace/SOCK_Dgram.cpp b/ace/SOCK_Dgram.cpp index f8b1e07d813..d52b30d3063 100644 --- a/ace/SOCK_Dgram.cpp +++ b/ace/SOCK_Dgram.cpp @@ -4,6 +4,7 @@ #define ACE_BUILD_DLL #include "ace/SOCK_Dgram.h" +#include "ace/Synch.h" ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_Dgram) @@ -28,18 +29,18 @@ ACE_SOCK_Dgram::recv (iovec *io_vec, ACE_Addr &addr, int flags) const u_long inlen; if (ACE_OS::ioctl (this->get_handle (), - FIONREAD, (u_long *) &inlen) == -1) + FIONREAD, (u_long *) &inlen) == -1) return -1; else if (inlen > 0) { ACE_NEW_RETURN (io_vec->iov_base, char[inlen], -1); io_vec->iov_len = ACE_OS::recvfrom (this->get_handle (), - (char *) io_vec->iov_base, - inlen, - flags, - (sockaddr *) saddr, - &addr_len); + (char *) io_vec->iov_base, + inlen, + flags, + (sockaddr *) saddr, + &addr_len); addr.set_size (addr_len); return io_vec->iov_len; } @@ -67,10 +68,10 @@ ACE_SOCK_Dgram::shared_open (const ACE_Addr &local, int protocol_family) if (&local == &ACE_Addr::sap_any && protocol_family == PF_INET) { if (ACE::bind_port (this->get_handle ()) == -1) - error = 1; + error = 1; } else if (ACE_OS::bind (this->get_handle (), (sockaddr *) local.get_addr (), - local.get_size ()) == -1) + local.get_size ()) == -1) error = 1; if (error) @@ -83,9 +84,9 @@ ACE_SOCK_Dgram::shared_open (const ACE_Addr &local, int protocol_family) // datagram ``server''... ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local, - int protocol_family, - int protocol, - int reuse_addr) + int protocol_family, + int protocol, + int reuse_addr) : ACE_SOCK (SOCK_DGRAM, protocol_family, protocol, reuse_addr) { ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram"); @@ -97,13 +98,13 @@ ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local, int ACE_SOCK_Dgram::open (const ACE_Addr &local, - int protocol_family, - int protocol, - int reuse_addr) + int protocol_family, + int protocol, + int reuse_addr) { ACE_TRACE ("ACE_SOCK_Dgram::open"); if (ACE_SOCK::open (SOCK_DGRAM, protocol_family, - protocol, reuse_addr) == -1) + protocol, reuse_addr) == -1) return -1; else return this->shared_open (local, protocol_family); @@ -115,9 +116,9 @@ ACE_SOCK_Dgram::open (const ACE_Addr &local, ssize_t ACE_SOCK_Dgram::send (const iovec iov[], - size_t n, - const ACE_Addr &addr, - int flags) const + size_t n, + const ACE_Addr &addr, + int flags) const { ACE_TRACE ("ACE_SOCK_Dgram::send"); msghdr send_msg; @@ -140,9 +141,9 @@ ACE_SOCK_Dgram::send (const iovec iov[], ssize_t ACE_SOCK_Dgram::recv (iovec iov[], - size_t n, - ACE_Addr &addr, - int flags) const + size_t n, + ACE_Addr &addr, + int flags) const { ACE_TRACE ("ACE_SOCK_Dgram::recv"); msghdr recv_msg; @@ -159,9 +160,100 @@ ACE_SOCK_Dgram::recv (iovec iov[], recv_msg.msg_accrightslen = 0; ssize_t status = ACE_OS::recvmsg (this->get_handle (), - &recv_msg, flags); + &recv_msg, flags); addr.set_size (recv_msg.msg_namelen); return status; } +#else /* ACE_HAS_MSG */ + +// Send an iovec of size N to ADDR as a datagram (connectionless +// version). + +ssize_t +ACE_SOCK_Dgram::send (const iovec iov[], + size_t n, + const ACE_Addr &addr, + int flags) const +{ + ACE_TRACE ("ACE_SOCK_Dgram::send"); + + size_t length = 0; + size_t i; + + // Determine the total length of all the buffers in <iov>. + for (i = 0; i < n; i++) + if (iov[i].iov_len < 0) + return -1; + else + length += iov[i].iov_len; + + char *buf; + +#if defined (ACE_HAS_ALLOCA) + buf = (iovec *) alloca (length); +#else + ACE_NEW_RETURN (buf, length, -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + char *ptr = buf; + + for (i = 0; i < n; i++) + { + ACE_OS::memcpy (ptr, iov[i].iov_base, iov[i].iov_len); + ptr += iov[i].iov_len; + } + + ssize_t result = ACE_SOCK_Dgram::send (buf, length, addr, flags); +#if !defined (ACE_HAS_ALLOCA) + delete [] buf; +#endif /* !defined (ACE_HAS_ALLOCA) */ + return result; +} + +// Recv an iovec of size N to ADDR as a datagram (connectionless +// version). + +ssize_t +ACE_SOCK_Dgram::recv (iovec iov[], + size_t n, + ACE_Addr &addr, + int flags) const +{ + ACE_TRACE ("ACE_SOCK_Dgram::recv"); + + ssize_t length = 0; + size_t i; + + for (i = 0; i < n; i++) + if (iov[i].iov_len < 0) + return -1; + else + length += iov[i].iov_len; + +#if defined (ACE_HAS_ALLOCA) + buf = (iovec *) alloca (length); +#else + ACE_NEW_RETURN (buf, length, -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + length = ACE_SOCK_Dgram::recv (buf, length, addr, flags); + + if (length != -1) + { + char *ptr = buf; + + for (i = 0; i < n; i++) + { + ACE_OS::memcpy (iov[i].iov_base, ptr, iov[i].iov_len); + ptr += iov[i].iov_len; + } + } + +#if !defined (ACE_HAS_ALLOCA) + delete [] buf; +#endif /* !defined (ACE_HAS_ALLOCA) */ + return length; +} + #endif /* ACE_HAS_MSG */ diff --git a/ace/SOCK_Dgram.h b/ace/SOCK_Dgram.h index 9a2f8aefce0..f754d8cb64c 100644 --- a/ace/SOCK_Dgram.h +++ b/ace/SOCK_Dgram.h @@ -31,28 +31,28 @@ public: // Default constructor. ACE_SOCK_Dgram (const ACE_Addr &local, - int protocol_family = PF_INET, - int protocol = 0, - int reuse_addr = 0); + int protocol_family = PF_INET, + int protocol = 0, + int reuse_addr = 0); // Initiate a socket dgram. int open (const ACE_Addr &local, - int protocol_family = PF_INET, - int protocol = 0, - int reuse_addr = 0); + int protocol_family = PF_INET, + int protocol = 0, + int reuse_addr = 0); // Initiate a socket dgram. // = Data transfer routines. ssize_t send (const void *buf, - size_t n, - const ACE_Addr &addr, - int flags = 0) const; + size_t n, + const ACE_Addr &addr, + int flags = 0) const; // Send an <n> byte <buf> to the datagram socket (uses sendto(3)). ssize_t recv (void *buf, - size_t n, - ACE_Addr &addr, - int flags = 0) const; + size_t n, + ACE_Addr &addr, + int flags = 0) const; // Receive an <n> byte <buf> from the datagram socket (uses // recvfrom(3)). @@ -63,21 +63,19 @@ public: // returns the number of bytes read. The caller is responsible for // deleting the member in the <iov_base> field of <io_vec>. -#if defined (ACE_HAS_MSG) ssize_t send (const iovec iov[], - size_t n, - const ACE_Addr &addr, - int flags = 0) const; + size_t n, + const ACE_Addr &addr, + int flags = 0) const; // Send an <iovec> of size <n> to the datagram socket (uses // sendmsg(3)). ssize_t recv (iovec iov[], - size_t n, - ACE_Addr &addr, - int flags = 0) const; + size_t n, + ACE_Addr &addr, + int flags = 0) const; // Recv an <iovec> of size <n> to the datagram socket (uses // recvmsg(3)). -#endif /* ACE_HAS_MSG */ void dump (void) const; // Dump the state of an object. @@ -87,7 +85,7 @@ public: protected: int shared_open (const ACE_Addr &local, - int protocol_family); + int protocol_family); // Open is shared by this and by <LSOCK_Dgram>. private: diff --git a/ace/SOCK_Dgram.i b/ace/SOCK_Dgram.i index e88d3906f4c..37af897057c 100644 --- a/ace/SOCK_Dgram.i +++ b/ace/SOCK_Dgram.i @@ -11,7 +11,7 @@ ACE_SOCK_Dgram::ACE_SOCK_Dgram (void) ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram"); } -// Send an N byte datagram to ADDR (connectionless version). +// <sendto> an N byte datagram to <addr> (connectionless version). inline ssize_t ACE_SOCK_Dgram::send (const void *buf, @@ -21,12 +21,13 @@ ACE_SOCK_Dgram::send (const void *buf, { ACE_TRACE ("ACE_SOCK_Dgram::send"); sockaddr *saddr = (sockaddr *) addr.get_addr (); - size_t len = addr.get_size (); - return ACE_OS::sendto (this->get_handle (), (const char *) buf, n, flags, - (struct sockaddr *) saddr, len); + size_t len = addr.get_size (); + return ACE_OS::sendto (this->get_handle (), + (const char *) buf, n, flags, + (struct sockaddr *) saddr, len); } -// Recv an n byte datagram to ADDR (connectionless version). +// <recvfrom> an n byte datagram (connectionless version). inline ssize_t ACE_SOCK_Dgram::recv (void *buf, @@ -35,11 +36,12 @@ ACE_SOCK_Dgram::recv (void *buf, int flags) const { ACE_TRACE ("ACE_SOCK_Dgram::recv"); - sockaddr *saddr = (sockaddr *) addr.get_addr (); - int addr_len = addr.get_size (); + sockaddr *saddr = (sockaddr *) addr.get_addr (); + int addr_len = addr.get_size (); - ssize_t status = ACE_OS::recvfrom (this->get_handle (), (char *) buf, n, flags, - (sockaddr *) saddr, &addr_len); + ssize_t status = ACE_OS::recvfrom (this->get_handle (), + (char *) buf, n, flags, + (sockaddr *) saddr, &addr_len); addr.set_size (addr_len); return status; } diff --git a/ace/SOCK_IO.cpp b/ace/SOCK_IO.cpp index 2be8c8ce329..5a2e9090046 100644 --- a/ace/SOCK_IO.cpp +++ b/ace/SOCK_IO.cpp @@ -52,11 +52,10 @@ ACE_SOCK_IO::send (size_t n, ...) const va_list argp; size_t total_tuples = n / 2; - ssize_t result; + iovec *iovp; #if defined (ACE_HAS_ALLOCA) - iovec *iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - iovec *iovp; ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -68,7 +67,7 @@ ACE_SOCK_IO::send (size_t n, ...) const iovp[i].iov_len = va_arg (argp, int); } - result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -88,13 +87,11 @@ ACE_SOCK_IO::recv (size_t n, ...) const ACE_TRACE ("ACE_SOCK_IO::recv"); va_list argp; - size_t total_tuples = n / 2; - ssize_t result; + size_t total_tuples = n / 2; + iovec *iovp; #if defined (ACE_HAS_ALLOCA) - iovec *iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - iovec *iovp; - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -106,7 +103,7 @@ ACE_SOCK_IO::recv (size_t n, ...) const iovp[i].iov_len = va_arg (argp, int); } - result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ diff --git a/ace/SPIPE_Stream.cpp b/ace/SPIPE_Stream.cpp index ab38d87e666..1a57c221e6e 100644 --- a/ace/SPIPE_Stream.cpp +++ b/ace/SPIPE_Stream.cpp @@ -30,12 +30,10 @@ ACE_SPIPE_Stream::send (size_t n, ...) const ACE_TRACE ("ACE_SPIPE_Stream::send"); va_list argp; size_t total_tuples = n / 2; - ssize_t result; + iovec *iovp; #if defined (ACE_HAS_ALLOCA) - iovec *iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - iovec *iovp; - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -47,7 +45,7 @@ ACE_SPIPE_Stream::send (size_t n, ...) const iovp[i].iov_len = va_arg (argp, int); } - result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -67,12 +65,10 @@ ACE_SPIPE_Stream::recv (size_t n, ...) const ACE_TRACE ("ACE_SPIPE_Stream::recv"); va_list argp; size_t total_tuples = n / 2; - ssize_t result; + iovec *iovp; #if defined (ACE_HAS_ALLOCA) - iovec *iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - iovec *iovp; - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -84,7 +80,7 @@ ACE_SPIPE_Stream::recv (size_t n, ...) const iovp[i].iov_len = va_arg (argp, int); } - result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ diff --git a/ace/config-hpux-10.x-g++.h b/ace/config-hpux-10.x-g++.h index ab34959076d..5da70fc0bd3 100644 --- a/ace/config-hpux-10.x-g++.h +++ b/ace/config-hpux-10.x-g++.h @@ -82,10 +82,10 @@ #define ACE_HAS_GETRUSAGE #define ACE_HAS_SIGINFO_T -#define ACE_HAS_UCONTEXT_T - -// Platform uses int for select() rather than fd_set. -// #define ACE_SELECT_USES_INT +#define ACE_LACKS_UCONTEXT_T +#define _CLOCKID_T +#define ACE_SELECT_USES_INT +#define ACE_LACKS_SI_ADDR // Platform has the XLI version of ACE_TLI. // #define ACE_HAS_XLI diff --git a/apps/JAWS/HTTP_Handler.cpp b/apps/JAWS/HTTP_Handler.cpp index 39718b7dd19..81a555204d5 100644 --- a/apps/JAWS/HTTP_Handler.cpp +++ b/apps/JAWS/HTTP_Handler.cpp @@ -256,9 +256,7 @@ HTTP_Handler::sockgets(char *buf, int n) // ---------------------------------------- // - // This is necessary for gcc to work with templates #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Acceptor<HTTP_Handler, ACE_SOCK_ACCEPTOR>; -template class Sock_Acceptor_Adapter<HTTP_Handler>; +template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/apps/JAWS/HTTP_Server.cpp b/apps/JAWS/HTTP_Server.cpp index 2e2df519924..3c59f0b939f 100644 --- a/apps/JAWS/HTTP_Server.cpp +++ b/apps/JAWS/HTTP_Server.cpp @@ -130,3 +130,9 @@ ACE_STATIC_SVC_DEFINE (HTTP_Server, "HTTP_Server", ACE_SVC_OBJ_T, &ACE_SVC_NAME (HTTP_Server), ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, 0) + +// This is necessary for gcc to work with templates +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class LOCK_SOCK_Acceptor<ACE_Thread_Mutex>; +template class ACE_Oneshot_Acceptor<HTTP_Handler, ONESHOT_SOCK_ACCEPTOR>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/examples/Logger/Acceptor-server/server_loggerd.cpp b/examples/Logger/Acceptor-server/server_loggerd.cpp index 20b0bb3d0af..d54871311a3 100644 --- a/examples/Logger/Acceptor-server/server_loggerd.cpp +++ b/examples/Logger/Acceptor-server/server_loggerd.cpp @@ -85,12 +85,8 @@ public: // = Initialization and termination methods. Logging_Handler (void); - virtual void destroy (void); - // Ensure dynamic allocation. - // = Hooks for opening and closing handlers. virtual int open (void *); - virtual int close (u_long); protected: // = Demultiplexing hooks. @@ -113,13 +109,6 @@ Logging_Handler::Logging_Handler (void) { } -void -Logging_Handler::destroy (void) -{ - REACTOR::instance ()->cancel_timer (this); - this->peer ().close (); -} - int Logging_Handler::handle_timeout (const ACE_Time_Value &, const void *arg) @@ -218,16 +207,6 @@ Logging_Handler::open (void *) } } -// Perform termination activities when deregistered from the -// ACE_Reactor. - -int -Logging_Handler::close (u_long) -{ - this->destroy (); - return 0; -} - int main (int argc, char *argv[]) { diff --git a/examples/Logger/simple-server/Logging_Acceptor.cpp b/examples/Logger/simple-server/Logging_Acceptor.cpp index c971f3537e9..96ef694d4a3 100644 --- a/examples/Logger/simple-server/Logging_Acceptor.cpp +++ b/examples/Logger/simple-server/Logging_Acceptor.cpp @@ -1,4 +1,3 @@ - // $Id$ #include "Logging_Acceptor.h" @@ -51,7 +50,9 @@ Logging_Acceptor::get_handle (void) const int Logging_Acceptor::handle_input (ACE_HANDLE) { - Logging_Handler *svc_handler = new Logging_Handler; + Logging_Handler *svc_handler; + + ACE_NEW_RETURN (svc_handler, Logging_Handler, -1); // Accept the connection from a client client daemon. diff --git a/examples/Logger/simple-server/Logging_Acceptor.h b/examples/Logger/simple-server/Logging_Acceptor.h index b653774ddd0..bfc5bbb3d3e 100644 --- a/examples/Logger/simple-server/Logging_Acceptor.h +++ b/examples/Logger/simple-server/Logging_Acceptor.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY diff --git a/examples/Logger/simple-server/Logging_Handler.cpp b/examples/Logger/simple-server/Logging_Handler.cpp index 5ffc425c5c4..f6aec6db542 100644 --- a/examples/Logger/simple-server/Logging_Handler.cpp +++ b/examples/Logger/simple-server/Logging_Handler.cpp @@ -106,27 +106,39 @@ Logging_Handler::open (void) return -1; else { - ACE_OS::strncpy (this->host_name_, addr.get_host_name (), MAXHOSTNAMELEN + 1); + ACE_OS::strncpy (this->host_name_, + addr.get_host_name (), + MAXHOSTNAMELEN + 1); if (REACTOR::instance ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) can't register with reactor\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) can't register with reactor\n"), + -1); else if (REACTOR::instance ()->schedule_timer - (this, (const void *) this, ACE_Time_Value (2), ACE_Time_Value (2)) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "can'(%P|%t) t register with reactor\n"), -1); + (this, (const void *) this, + ACE_Time_Value (2), + ACE_Time_Value (2)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "can'(%P|%t) t register with reactor\n"), + -1); else - ACE_DEBUG ((LM_DEBUG, "(%P|%t) connected with %s\n", this->host_name_)); + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) connected with %s\n", + this->host_name_)); return 0; } } -// Perform termination activities when deregistered from the ACE_Reactor. +// Perform termination activities when deregistered from the +// ACE_Reactor. int -Logging_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +Logging_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask mask) { // Must be allocated dynamically! - delete this; + if (mask == ACE_Event_Handler::READ_MASK) + delete this; return 0; } @@ -136,5 +148,5 @@ int Logging_Handler::close (void) { return this->handle_close (ACE_INVALID_HANDLE, - ACE_Event_Handler::ALL_EVENTS_MASK); + ACE_Event_Handler::READ_MASK); } diff --git a/examples/Logger/simple-server/server_loggerd.cpp b/examples/Logger/simple-server/server_loggerd.cpp index 5d355ca2cc9..481ed097366 100644 --- a/examples/Logger/simple-server/server_loggerd.cpp +++ b/examples/Logger/simple-server/server_loggerd.cpp @@ -48,17 +48,22 @@ main (int argc, char *argv[]) if (peer_acceptor.open (addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); else if (REACTOR::instance ()->register_handler - (&peer_acceptor, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); + (&peer_acceptor, + ACE_Event_Handler::ACCEPT_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "registering service with ACE_Reactor\n"), + -1); // Run forever, performing logging service. - ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting up server logging daemon\n")); + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) starting up server logging daemon\n")); while (!finished) REACTOR::instance ()->handle_events (); - ACE_DEBUG ((LM_DEBUG, "(%P|%t) shutting down server logging daemon\n")); + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) shutting down server logging daemon\n")); return 0; } |