Skip to content

Commit

Permalink
fix concurrency and too-early-request issues for windows ip_check
Browse files Browse the repository at this point in the history
  • Loading branch information
simpsont-oci committed May 13, 2021
1 parent 474ac23 commit 04d70c6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions ACE/ace/Sock_Connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1473,21 +1473,32 @@ 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
// endpoint addresses and see if any match the desired family.
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.
Expand Down

0 comments on commit 04d70c6

Please sign in to comment.