diff options
author | Timothy Simpson <simpsont@objectcomputing.com> | 2021-05-13 13:51:58 -0500 |
---|---|---|
committer | Timothy Simpson <simpsont@objectcomputing.com> | 2021-05-13 13:51:58 -0500 |
commit | 04d70c6c157074e053e4040d2d869c972be39eff (patch) | |
tree | d2d30ea5d28f4618468c821b9b740e5d287796d9 | |
parent | 474ac236d18be4e283d70b8c8b43a4e54039a5a6 (diff) | |
download | ATCD-04d70c6c157074e053e4040d2d869c972be39eff.tar.gz |
fix concurrency and too-early-request issues for windows ip_check
-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..26118d5629f 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 int recursing = 0; + if (recursing) return recursing; + // 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 = 1; ACE::get_ip_interfaces (if_cnt, if_addrs); - ipvn_enabled = 0; - for (size_t i = 0; ipvn_enabled == 0 && i < if_cnt; i++) + recursing = 0; + + 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 true; + + 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. |