diff options
author | vzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-09-02 14:51:58 +0000 |
---|---|---|
committer | vzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-09-02 14:51:58 +0000 |
commit | 9d446c24621ade4dd8d4fe5a65e41bad9ff2485a (patch) | |
tree | b12714f96f26114214f514ee8c1fe6bdc34d2706 /ACE/ace | |
parent | 551e3347e4a9c5f92614c8069e8c6a67ef761bb1 (diff) | |
download | ATCD-9d446c24621ade4dd8d4fe5a65e41bad9ff2485a.tar.gz |
Thu Sep 2 14:46:56 UTC 2010 Vladimir Zykov <vladimir.zykov@prismtech.com>
* ace/Acceptor.cpp:
* ace/SOCK_IO.cpp:
* ace/SOCK_Dgram.cpp:
* ace/ACE.cpp:
* tests/SOCK_Test.cpp:
* tests/MT_SOCK_Test.cpp:
* NEWS:
Reverted both commits by Steve Huston related to handle_ready()
and a NEWS entry.
Wed Sep 1 19:31:24 UTC 2010 Steve Huston <shuston@riverace.com>
Fri Aug 27 19:17:11 UTC 2010 Steve Huston <shuston@riverace.com>
This is necessary for a quick release of 1.8.2.
Diffstat (limited to 'ACE/ace')
-rw-r--r-- | ACE/ace/ACE.cpp | 55 | ||||
-rw-r--r-- | ACE/ace/Acceptor.cpp | 21 | ||||
-rw-r--r-- | ACE/ace/SOCK_Dgram.cpp | 61 | ||||
-rw-r--r-- | ACE/ace/SOCK_IO.cpp | 22 |
4 files changed, 123 insertions, 36 deletions
diff --git a/ACE/ace/ACE.cpp b/ACE/ace/ACE.cpp index 925be0a034b..ba5bbd3a662 100644 --- a/ACE/ace/ACE.cpp +++ b/ACE/ace/ACE.cpp @@ -33,9 +33,9 @@ extern "C" int maxFiles; #include "ace/ACE.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_POLL) +#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) # include "ace/OS_NS_poll.h" -#endif /* ACE_HAS_POLL */ +#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ // Open versioned namespace, if enabled by the user. ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -2169,19 +2169,14 @@ ACE::handle_ready (ACE_HANDLE handle, int write_ready, int exception_ready) { -#if defined (ACE_HAS_POLL) +#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) + ACE_UNUSED_ARG (write_ready); ACE_UNUSED_ARG (exception_ready); struct pollfd fds; fds.fd = handle; - fds.events = read_ready ? POLLIN : 0; - - if( write_ready ) - { - fds.events |= POLLOUT; - } - + fds.events = read_ready ? POLLIN : POLLOUT; fds.revents = 0; int result = ACE_OS::poll (&fds, 1, timeout); @@ -2204,9 +2199,21 @@ ACE::handle_ready (ACE_HANDLE handle, exception_ready ? handle_set.fdset () : 0, // exception_fds. timeout); -#endif /* ACE_HAS_POLL */ +#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ - return result; + switch (result) + { + case 0: // Timer expired. + errno = ETIME; + /* FALLTHRU */ + case -1: // we got here directly - select() returned -1. + return -1; + case 1: // Handle has data. + /* FALLTHRU */ + default: // default is case result > 0; return a + // ACE_ASSERT (result == 1); + return result; + } } int @@ -2521,7 +2528,7 @@ ACE::handle_timed_complete (ACE_HANDLE h, { ACE_TRACE ("ACE::handle_timed_complete"); -#if !defined (ACE_WIN32) && defined (ACE_HAS_POLL) +#if !defined (ACE_WIN32) && defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) struct pollfd fds; @@ -2534,7 +2541,7 @@ ACE::handle_timed_complete (ACE_HANDLE h, ACE_Handle_Set wr_handles; rd_handles.set_bit (h); wr_handles.set_bit (h); -#endif /* !ACE_WIN32 && ACE_HAS_POLL */ +#endif /* !ACE_WIN32 && ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ #if defined (ACE_WIN32) // Winsock is different - it sets the exception bit for failed connect, @@ -2554,7 +2561,7 @@ ACE::handle_timed_complete (ACE_HANDLE h, ex_handles, timeout); #else -# if defined (ACE_HAS_POLL) +# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) int n = ACE_OS::poll (&fds, 1, timeout); @@ -2572,7 +2579,7 @@ ACE::handle_timed_complete (ACE_HANDLE h, wr_handles, 0, timeout); -# endif /* ACE_HAS_POLL */ +# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ #endif /* ACE_WIN32 */ // If we failed to connect within the time period allocated by the @@ -2606,18 +2613,18 @@ ACE::handle_timed_complete (ACE_HANDLE h, } #else if (is_tli) -# if defined (ACE_HAS_POLL) +# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) need_to_check = (fds.revents & POLLIN) && !(fds.revents & POLLOUT); # else need_to_check = rd_handles.is_set (h) && !wr_handles.is_set (h); -# endif /* ACE_HAS_POLL */ +# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ else -# if defined (ACE_HAS_POLL) +# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) need_to_check = (fds.revents & POLLIN); # else need_to_check = true; -# endif /* ACE_HAS_POLL */ +# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ #endif /* ACE_WIN32 */ if (need_to_check) @@ -2679,7 +2686,7 @@ ACE::handle_timed_accept (ACE_HANDLE listener, if (listener == ACE_INVALID_HANDLE) return -1; -#if defined (ACE_HAS_POLL) +#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) struct pollfd fds; @@ -2691,13 +2698,13 @@ ACE::handle_timed_accept (ACE_HANDLE listener, // Use the select() implementation rather than poll(). ACE_Handle_Set rd_handle; rd_handle.set_bit (listener); -#endif /* ACE_HAS_POLL */ +#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ // We need a loop here if <restart> is enabled. for (;;) { -#if defined (ACE_HAS_POLL) +#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) int n = ACE_OS::poll (&fds, 1, timeout); @@ -2713,7 +2720,7 @@ ACE::handle_timed_accept (ACE_HANDLE listener, int n = ACE_OS::select (select_width, rd_handle, 0, 0, timeout); -#endif /* ACE_HAS_POLL */ +#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ switch (n) { diff --git a/ACE/ace/Acceptor.cpp b/ACE/ace/Acceptor.cpp index 6b1a55ae6ff..bf46bff01a5 100644 --- a/ACE/ace/Acceptor.cpp +++ b/ACE/ace/Acceptor.cpp @@ -10,10 +10,12 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Acceptor.h" +#include "ace/Handle_Set.h" #include "ace/Svc_Handler.h" #include "ace/WFMO_Reactor.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_select.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -363,9 +365,17 @@ template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input (ACE_HANDLE listener) { ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input"); + ACE_Handle_Set conn_handle; // Default is "timeout (0, 0)," which means "poll." ACE_Time_Value timeout; +# if defined (ACE_WIN32) + // This arg is ignored on Windows and causes pointer truncation + // warnings on 64-bit compiles + int select_width = 0; +# else + int select_width = int (listener) + 1; +# endif /* ACE_WIN32 */ // Accept connections from clients. Note that a loop is used for two // reasons: @@ -422,13 +432,18 @@ ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input (ACE_HANDLE listene ACE_TEXT ("activate_svc_handler"))); return 0; } + + conn_handle.set_bit (listener); } // Now, check to see if there is another connection pending and // break out of the loop if there is none. - while (this->use_select_ && - ACE::handle_read_ready (listener, - &timeout) == 1); + while (this->use_select_ + && ACE_OS::select (select_width, + conn_handle, + 0, + 0, + &timeout) == 1); return 0; } diff --git a/ACE/ace/SOCK_Dgram.cpp b/ACE/ace/SOCK_Dgram.cpp index 8b546553df4..9df9dcb6094 100644 --- a/ACE/ace/SOCK_Dgram.cpp +++ b/ACE/ace/SOCK_Dgram.cpp @@ -2,11 +2,13 @@ #include "ace/SOCK_Dgram.h" +#include "ace/Handle_Set.h" #include "ace/Log_Msg.h" #include "ace/INET_Addr.h" #include "ace/ACE.h" #include "ace/OS_NS_string.h" #include "ace/OS_Memory.h" +#include "ace/OS_NS_sys_select.h" #include "ace/OS_NS_ctype.h" #include "ace/os_include/net/os_if.h" #include "ace/Truncate.h" @@ -50,7 +52,23 @@ ACE_SOCK_Dgram::recv (iovec *io_vec, { ACE_TRACE ("ACE_SOCK_Dgram::recv"); #if defined (FIONREAD) - switch (ACE::handle_read_ready (this->get_handle (), timeout)) + ACE_Handle_Set handle_set; + handle_set.reset (); + handle_set.set_bit (this->get_handle ()); + + // Check the status of the current socket to make sure there's data + // to recv (or time out). +# if defined (ACE_WIN32) + // This arg is ignored on Windows and causes pointer truncation + // warnings on 64-bit compiles. + int select_width = 0; +# else + int select_width = int (this->get_handle ()) + 1; +# endif /* ACE_WIN32 */ + switch (ACE_OS::select (select_width, + handle_set, + 0, 0, + timeout)) { case -1: return -1; @@ -433,7 +451,23 @@ ACE_SOCK_Dgram::recv (void *buf, int flags, const ACE_Time_Value *timeout) const { - switch (ACE::handle_read_ready (this->get_handle (), timeout)) + ACE_Handle_Set handle_set; + handle_set.reset (); + handle_set.set_bit (this->get_handle ()); + + // Check the status of the current socket. +#if defined (ACE_WIN32) + // This arg is ignored on Windows and causes pointer truncation + // warnings on 64-bit compiles. + int select_width = 0; +#else + int select_width = int (this->get_handle ()) + 1; +#endif /* ACE_WIN32 */ + switch (ACE_OS::select (select_width, + handle_set, + 0, + 0, + timeout)) { case -1: return -1; @@ -444,9 +478,8 @@ ACE_SOCK_Dgram::recv (void *buf, /* NOTREACHED */ default: // Goes fine, call <recv> to get data - break; + return this->recv (buf, n, addr, flags); } - return this->recv (buf, n, addr, flags); } ssize_t @@ -456,8 +489,23 @@ ACE_SOCK_Dgram::send (const void *buf, int flags, const ACE_Time_Value *timeout) const { + ACE_Handle_Set handle_set; + handle_set.reset (); + handle_set.set_bit (this->get_handle ()); + // Check the status of the current socket. - switch (ACE::handle_write_ready (this->get_handle (), timeout)) +#if defined (ACE_WIN32) + // This arg is ignored on Windows and causes pointer truncation + // warnings on 64-bit compiles. + int select_width = 0; +#else + int select_width = int (this->get_handle ()) + 1; +#endif /* ACE_WIN32 */ + switch (ACE_OS::select (select_width, + 0, + handle_set, + 0, + timeout)) { case -1: return -1; @@ -468,9 +516,8 @@ ACE_SOCK_Dgram::send (const void *buf, /* NOTREACHED */ default: // Goes fine, call <send> to transmit the data. - break; + return this->send (buf, n, addr, flags); } - return this->send (buf, n, addr, flags); } int diff --git a/ACE/ace/SOCK_IO.cpp b/ACE/ace/SOCK_IO.cpp index cd3237caf17..41897e680de 100644 --- a/ACE/ace/SOCK_IO.cpp +++ b/ACE/ace/SOCK_IO.cpp @@ -2,6 +2,8 @@ #include "ace/SOCK_IO.h" +#include "ace/Handle_Set.h" +#include "ace/OS_NS_sys_select.h" #include "ace/OS_NS_sys_socket.h" #include "ace/OS_Memory.h" #include "ace/Truncate.h" @@ -35,8 +37,24 @@ ACE_SOCK_IO::recvv (iovec *io_vec, { ACE_TRACE ("ACE_SOCK_IO::recvv"); #if defined (FIONREAD) + ACE_Handle_Set handle_set; + handle_set.reset (); + handle_set.set_bit (this->get_handle ()); + io_vec->iov_base = 0; - switch (ACE::handle_read_ready (this->get_handle (), timeout)) + + // Check the status of the current socket. +# if defined (ACE_WIN32) + // This arg is ignored on Windows and causes pointer truncation + // warnings on 64-bit compiles. + int select_width = 0; +# else + int select_width = int (this->get_handle ()) + 1; +# endif /* ACE_WIN32 */ + switch (ACE_OS::select (select_width, + handle_set, + 0, 0, + timeout)) { case -1: return -1; @@ -46,7 +64,7 @@ ACE_SOCK_IO::recvv (iovec *io_vec, return -1; /* NOTREACHED */ default: - // Goes fine, fall through to get the data. + // Goes fine, fallthrough to get data break; } |