diff options
author | Adam Mitz <mitza@objectcomputing.com> | 2021-05-24 09:47:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-24 09:47:58 -0500 |
commit | 84438e5c0dfa16596fae1f9247d42e05b95db3c6 (patch) | |
tree | 4809ffa6b30eb3125ad1831c94a29eeec091fe3d /ACE | |
parent | 705b8d95eb5abd258ff7d46c8a553d102be19e22 (diff) | |
parent | bd42ac334e90816ed0a8778b9e45c1cc9d1b2447 (diff) | |
download | ATCD-84438e5c0dfa16596fae1f9247d42e05b95db3c6.tar.gz |
Merge pull request #1508 from simpsont-oci/ace6tao2_ip_check_fix_v2
[ACE6] Fix SocketConnect::ip_check() Concurrency and Too-Early Request Issues for Windows
Diffstat (limited to 'ACE')
-rw-r--r-- | ACE/ace/Sock_Connect.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ACE/ace/Sock_Connect.cpp b/ACE/ace/Sock_Connect.cpp index 43606fa2f3c..f76d137b311 100644 --- a/ACE/ace/Sock_Connect.cpp +++ b/ACE/ace/Sock_Connect.cpp @@ -1473,6 +1473,9 @@ ip_check (int &ipvn_enabled, int pf) { #if defined (ACE_WIN32) + static bool recursing = false; + if (recursing) return 1; + // as of the release of Windows 2008, even hosts that have IPv6 interfaces disabled // will still permit the creation of a PF_INET6 socket, thus rendering the socket // creation test inconsistent. The recommended solution is to get the list of @@ -1480,14 +1483,22 @@ ip_check (int &ipvn_enabled, int pf) ACE_INET_Addr *if_addrs = 0; size_t if_cnt = 0; - ipvn_enabled = 1; // assume enabled to avoid recursion during interface lookup. + // assume enabled to avoid recursion during interface lookup. + recursing = true; ACE::get_ip_interfaces (if_cnt, if_addrs); - ipvn_enabled = 0; - for (size_t i = 0; ipvn_enabled == 0 && i < if_cnt; i++) + recursing = false; + + bool found = false; + for (size_t i = 0; !found && i < if_cnt; i++) { - ipvn_enabled = (if_addrs[i].get_type () == pf); + found = (if_addrs[i].get_type () == pf); } delete [] if_addrs; + + // If the list of interfaces is empty, we've tried too quickly. Assume enabled, but don't cache the result + if (!if_cnt) return 1; + + ipvn_enabled = found ? 1 : 0; #else // Determine if the kernel has IPv6 support by attempting to // create a PF_INET6 socket and see if it fails. |