diff options
author | Steve Huston <shuston@riverace.com> | 2001-04-23 17:50:30 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2001-04-23 17:50:30 +0000 |
commit | 02aa337f9d81f7d2b80b66f5f4df9dd4526a1b35 (patch) | |
tree | 0210bf354a22bdab577299d74d4ecbbd0234bbfe /ace | |
parent | 5e1e1f6bda615ae7f41a1e22ded535f0f9ecc893 (diff) | |
download | ATCD-02aa337f9d81f7d2b80b66f5f4df9dd4526a1b35.tar.gz |
ChangeLogTag:Mon Apr 23 13:36:27 2001 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/ACE.cpp | 15 | ||||
-rw-r--r-- | ace/Connector.cpp | 24 | ||||
-rw-r--r-- | ace/README | 3 | ||||
-rw-r--r-- | ace/SOCK_Connector.cpp | 25 | ||||
-rw-r--r-- | ace/config-win32-common.h | 3 |
5 files changed, 43 insertions, 27 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp index 9e2036c215f..a6deb165571 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -2532,6 +2532,8 @@ ACE::handle_timed_complete (ACE_HANDLE h, #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, + // unlike other platforms, where the read bit is set. ACE_Handle_Set ex_handles; ex_handles.set_bit (h); #endif /* ACE_WIN32 */ @@ -2540,7 +2542,7 @@ ACE::handle_timed_complete (ACE_HANDLE h, #if defined (ACE_WIN32) int n = ACE_OS::select (int (h) + 1, - rd_handles, + 0, wr_handles, ex_handles, timeout); @@ -2572,8 +2574,15 @@ ACE::handle_timed_complete (ACE_HANDLE h, // ready for writing, which may indicate a problem. But we need to // make sure... #if defined (ACE_WIN32) - ACE_UNUSED_ARG (is_tli); - need_to_check = rd_handles.is_set (h) || ex_handles.is_set (h); + if (ex_handles.is_set (h)) + h = ACE_INVALID_HANDLE; + else + // There's a funky time window on some Win32 versions (pre-Win2000) + // where the socket is marked complete, but operations will still + // fail. We need to find if this is one of those and return an error + // if so - the caller will then need to decide to ignore it or sleep + // and retry (see SOCK_Connector.cpp) + need_to_check = 1; #elif defined (VXWORKS) ACE_UNUSED_ARG (is_tli); diff --git a/ace/Connector.cpp b/ace/Connector.cpp index 15eef258692..a2261613ae0 100644 --- a/ace/Connector.cpp +++ b/ace/Connector.cpp @@ -339,20 +339,24 @@ ACE_Connector<SH, PR_CO_2>::handle_output (ACE_HANDLE handle) PR_AD raddr; -#if defined (ACE_HAS_BROKEN_NON_BLOCKING_CONNECTS) - // Win32 has a timing problem - if you check to see if the - // connection has completed too fast, it will fail - so wait 35 - // millisecond to let it catch up. - ACE_Time_Value tv (0, ACE_NON_BLOCKING_BUG_DELAY); - ACE_OS::sleep (tv); -#endif /* ACE_HAS_BROKEN_NON_BLOCKING_CONNECTS */ - // Check to see if we're connected. if (ast->svc_handler ()->peer ().get_remote_addr (raddr) != -1) this->activate_svc_handler (ast->svc_handler ()); else // Somethings gone wrong, so close down... - ast->svc_handler ()->close (0); - + { +#if defined (ACE_WIN32) + ACE_DEBUG ((LM_DEBUG, "errno %d; Sleeping to retry get_remote_addr\n", errno)); + // Win32 (at least prior to Windows 2000) has a timing problem. + // If you check to see if the connection has completed too fast, + // it will fail - so wait 35 milliseconds to let it catch up. + ACE_Time_Value tv (0, ACE_NON_BLOCKING_BUG_DELAY); + ACE_OS::sleep (tv); + if (ast->svc_handler ()->peer ().get_remote_addr (raddr) != -1) + this->activate_svc_handler (ast->svc_handler ()); + else // do the svc handler close below... +#endif /* ACE_HAS_BROKEN_NON_BLOCKING_CONNECTS */ + ast->svc_handler ()->close (0); + } delete ast; return 0; } diff --git a/ace/README b/ace/README index 7ca0c70e20f..eba23c9d8bd 100644 --- a/ace/README +++ b/ace/README @@ -218,9 +218,6 @@ ACE_HAS_BROKEN_MMAP_H HP/UX does not wrap the ACE_HAS_BROKEN_NESTED_TEMPLATES MSVC has trouble with defining STL containers for nested structs and classes -ACE_HAS_BROKEN_NON_BLOCKING_CONNECTS Platform has a bug with - non-blocking connects (e.g., - WinNT 4.0) ACE_HAS_BROKEN_POSIX_TIME Platform defines struct timespec in <sys/timers.h> ACE_HAS_BROKEN_RANDR OS/compiler's header files are diff --git a/ace/SOCK_Connector.cpp b/ace/SOCK_Connector.cpp index 6006bef20c1..062df45f423 100644 --- a/ace/SOCK_Connector.cpp +++ b/ace/SOCK_Connector.cpp @@ -215,24 +215,33 @@ ACE_SOCK_Connector::complete (ACE_SOCK_Stream &new_stream, const ACE_Time_Value *tv) { ACE_TRACE ("ACE_SOCK_Connector::complete"); -#if defined (ACE_HAS_BROKEN_NON_BLOCKING_CONNECTS) - // Win32 has a timing problem - if you check to see if the - // connection has completed too fast, it will fail - so wait - // <ACE_NON_BLOCKING_BUG_DELAY> microseconds to let it catch up. - ACE_Time_Value time (0, ACE_NON_BLOCKING_BUG_DELAY); - ACE_OS::sleep (time); -#endif /* ACE_HAS_BROKEN_NON_BLOCKING_CONNECTS */ ACE_HANDLE h = ACE::handle_timed_complete (new_stream.get_handle (), tv); // We failed to get connected. if (h == ACE_INVALID_HANDLE) { +#if defined (ACE_WIN32) + // Win32 has a timing problem - if you check to see if the + // connection has completed too fast, it will fail - so wait + // <ACE_NON_BLOCKING_BUG_DELAY> microseconds to let it catch up + // then retry to see if it's a real failure. + ACE_Time_Value time (0, ACE_NON_BLOCKING_BUG_DELAY); + ACE_OS::sleep (time); + h = ACE::handle_timed_complete (new_stream.get_handle (), + tv); + if (h == ACE_INVALID_HANDLE) + { +#endif /* ACE_WIN32 */ // Save/restore errno. ACE_Errno_Guard error (errno); new_stream.close (); return -1; +#if defined (ACE_WIN32) + } +#endif /* ACE_WIN32 */ } - else if (remote_sap != 0) + + if (remote_sap != 0) { int len = remote_sap->get_size (); sockaddr *addr = ACE_reinterpret_cast (sockaddr *, diff --git a/ace/config-win32-common.h b/ace/config-win32-common.h index afad57f010f..298243cde78 100644 --- a/ace/config-win32-common.h +++ b/ace/config-win32-common.h @@ -298,9 +298,6 @@ typedef unsigned long long ACE_UINT64; #define ACE_LACKS_KEY_T -// Platform support for non-blocking connects is broken -#define ACE_HAS_BROKEN_NON_BLOCKING_CONNECTS - // No system support for replacing any previous mappings. #define ACE_LACKS_AUTO_MMAP_REPLACEMENT |