summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2010-11-05 14:22:34 +0000
committerSteve Huston <shuston@riverace.com>2010-11-05 14:22:34 +0000
commit163fadb68e0ac4ce1ade31aae6502377f65e566a (patch)
treedac314475308e5679c54c11f8bc84315d96b8051
parent82e4e23554996d2c6a9a65276f9c006086977f06 (diff)
downloadATCD-163fadb68e0ac4ce1ade31aae6502377f65e566a.tar.gz
ChangeLogTag:Thu Nov 4 15:17:51 UTC 2010 Steve Huston <shuston@riverace.com>
-rw-r--r--ChangeLog11
-rw-r--r--ace/INET_Addr.cpp23
-rw-r--r--tests/INET_Addr_Test.cpp25
3 files changed, 51 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index f1ab07c8fcc..82d314e1967 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Thu Nov 4 15:17:51 UTC 2010 Steve Huston <shuston@riverace.com>
+
+ * ace/INET_Addr.cpp (set): For platforms that have the GNU-extended
+ gethostbyname2_r() function, use it instead of getaddrinfo() for
+ a IPv6 hostname lookup. Customer reports that it getaddrinfo() is
+ hugely slower than gethostbyname2 on large vlans. The alternate
+ code is used if ACE_HAS_GETHOSTBYNAME2 is set in config.h.
+ (This is a revised fix from Tue Nov 2 00:18:34 UTC 2010)
+
+ * tests/INET_Addr_Test.cpp: Add some IPv6 address and name lookups.
+
Tue Nov 2 00:18:34 UTC 2010 Steve Huston <shuston@riverace.com>
* ace/INET_Addr.cpp (set): For platforms that have the GNU-extended
diff --git a/ace/INET_Addr.cpp b/ace/INET_Addr.cpp
index 54bc4f74dd9..dd1dc25ea75 100644
--- a/ace/INET_Addr.cpp
+++ b/ace/INET_Addr.cpp
@@ -350,17 +350,26 @@ ACE_INET_Addr::set (u_short port_number,
{
# if defined (ACE_HAS_GETHOSTBYNAME2)
hostent hentry;
+ hostent *hp;
ACE_HOSTENT_DATA buf;
int h_error = 0; // Not the same as errno!
- hostent *hp = ::gethostbyname2_r (host_name, AF_INET6, &hentry,
- buf, &h_error);
- if (hp != 0)
+ if (0 == ::gethostbyname2_r (host_name, AF_INET6, &hentry,
+ buf, sizeof(buf), &hp, &h_error))
{
- this->set_type (hp->h_addrtype);
- this->set_addr (hp->h_addr, hp->h_length);
- this->set_port_number (port_number, encode);
- return 0;
+ if (hp != 0)
+ {
+ struct sockaddr_in6 v6;
+ ACE_OS::memset (&v6, 0, sizeof (v6));
+ v6.sin6_family = AF_INET6;
+ (void) ACE_OS::memcpy ((void *) &v6.sin6_addr,
+ hp->h_addr,
+ hp->h_length);
+ this->set_type (hp->h_addrtype);
+ this->set_addr (&v6, hp->h_length);
+ this->set_port_number (port_number, encode);
+ return 0;
+ }
}
errno = h_error;
if (address_family == AF_INET6)
diff --git a/tests/INET_Addr_Test.cpp b/tests/INET_Addr_Test.cpp
index 36e2e4c27a5..5a31f9314fa 100644
--- a/tests/INET_Addr_Test.cpp
+++ b/tests/INET_Addr_Test.cpp
@@ -217,8 +217,31 @@ int run_main (int, ACE_TCHAR *[])
status = 1;
}
}
- }
+ const char *ipv6_names[] = {
+ "naboo.dre.vanderbilt.edu",
+ "v6.ipv6-test.com",
+ 0
+ };
+ for (int i=0; ipv6_names[i] != 0; i++)
+ {
+ ACE_INET_Addr addr (80, ipv6_names[i]);
+ status |= check_type_consistency (addr);
+
+ if (0 != ACE_OS::strcmp (addr.get_host_name (), ipv6_names[i]))
+ {
+ ACE_ERROR ((LM_WARNING,
+ ACE_TEXT ("IPv6 name mismatch: %s (%s) != %s\n"),
+ addr.get_host_name (),
+ addr.get_host_addr (),
+ ipv6_names[i]));
+ status = 1;
+ }
+ }
+ }
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 tests done\n")));
+#else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_HAS_IPV6 not set; no IPv6 tests run\n")));
#endif
struct Address loopback_addresses[] =