Skip to content

Commit

Permalink
Merge pull request DOCGroup#1508 from simpsont-oci/ace6tao2_ip_check_…
Browse files Browse the repository at this point in the history
…fix_v2

[ACE6] Fix SocketConnect::ip_check() Concurrency and Too-Early Request Issues for Windows
  • Loading branch information
mitza-oci authored May 24, 2021
2 parents 705b8d9 + bd42ac3 commit 84438e5
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 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
// 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 = 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.
Expand Down

0 comments on commit 84438e5

Please sign in to comment.