diff options
author | Steve Huston <shuston@riverace.com> | 2010-08-27 19:46:10 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2010-08-27 19:46:10 +0000 |
commit | dbeb734d4a61148f7b4bfca010125c7f57627a1f (patch) | |
tree | 9090676d14d98470de5e6b470c6a2c602197bddb /ACE/tests/SOCK_Test.cpp | |
parent | ee6269f3809336ea9a1185dabd82b75372cab2fc (diff) | |
download | ATCD-dbeb734d4a61148f7b4bfca010125c7f57627a1f.tar.gz |
ChangeLogTag:Fri Aug 27 19:17:11 UTC 2010 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ACE/tests/SOCK_Test.cpp')
-rw-r--r-- | ACE/tests/SOCK_Test.cpp | 53 |
1 files changed, 16 insertions, 37 deletions
diff --git a/ACE/tests/SOCK_Test.cpp b/ACE/tests/SOCK_Test.cpp index 34000f53eee..2fa4e1f36e3 100644 --- a/ACE/tests/SOCK_Test.cpp +++ b/ACE/tests/SOCK_Test.cpp @@ -22,7 +22,6 @@ #include "test_config.h" #include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_sys_select.h" #include "ace/OS_NS_sys_wait.h" #include "ace/Thread.h" #include "ace/Time_Value.h" @@ -69,6 +68,17 @@ client (void *arg) if (cli_stream.disable (ACE_NONBLOCK) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("disable"))); + // Test Bug 3606 + const ACE_Time_Value def_timeout (ACE_DEFAULT_TIMEOUT); + ACE_Time_Value tv (def_timeout); + int result = ACE::handle_ready (cli_stream.get_handle (), &tv, + 1, // read_ready + 1, // write_ready + 0); + // we expect the handle to be at leat write_ready since it is freshly connected. + if (result == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("ACE::handle_ready")), 0); + // Send data to server (correctly handles "incomplete writes"). for (const char *c = ACE_ALPHABET; *c != '\0'; c++) @@ -104,36 +114,18 @@ server (void *arg) // calls... ACE_SOCK_Stream new_stream; ACE_INET_Addr cli_addr; - ACE_Handle_Set handle_set; const ACE_Time_Value def_timeout (ACE_DEFAULT_TIMEOUT); ACE_Time_Value tv (def_timeout); char buf[BUFSIZ]; const char *t = ACE_ALPHABET; - handle_set.reset (); - handle_set.set_bit (peer_acceptor->get_handle ()); - - int select_width; -# if defined (ACE_WIN64) - // This arg is ignored on Windows and causes pointer truncation - // warnings on 64-bit compiles. - select_width = 0; -# else - select_width = int (peer_acceptor->get_handle ()) + 1; -# endif /* ACE_WIN64 */ - int result = ACE_OS::select (select_width, - handle_set, - 0, 0, &tv); + int result = ACE::handle_read_ready (peer_acceptor->get_handle (), &tv); + ACE_ASSERT (tv == def_timeout); if (result == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("select")), 0); - else if (result == 0) - { - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) select timed out, shutting down\n"))); - return 0; - } + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("handle_read_ready")), 0); // Create a new ACE_SOCK_Stream endpoint (note automatic restart // if errno == EINTR). @@ -147,24 +139,11 @@ server (void *arg) if (new_stream.enable (ACE_NONBLOCK) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("enable")), 0); - handle_set.reset (); - handle_set.set_bit (new_stream.get_handle ()); - // Read data from client (terminate on error). - int select_width; for (ssize_t r_bytes; ;) { -# if defined (ACE_WIN64) - // This arg is ignored on Windows and causes pointer truncation - // warnings on 64-bit compiles. - select_width = 0; -# else - select_width = int (new_stream.get_handle ()) + 1; -# endif /* ACE_WIN64 */ - if (ACE_OS::select (select_width, - handle_set, - 0, 0, 0) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("select")), 0); + if (ACE::handle_read_ready (new_stream.get_handle (), 0) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("handle_read_ready")), 0); while ((r_bytes = new_stream.recv (buf, 1)) > 0) { |