summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2010-10-27 22:19:37 +0000
committerSteve Huston <shuston@riverace.com>2010-10-27 22:19:37 +0000
commitbea2cd2a1f4a82ac394001718f20baae1e5d84b6 (patch)
tree0097809130eef23a44767fd88845e6fb87ab1d60
parentfba193569e09cedb03dce32042b91dfc1dd43c24 (diff)
downloadATCD-bea2cd2a1f4a82ac394001718f20baae1e5d84b6.tar.gz
ChangeLogTag:Wed Oct 27 22:16:12 UTC 2010 Steve Huston <shuston@riverace.com>
-rw-r--r--ChangeLog9
-rw-r--r--ace/INET_Addr.cpp57
2 files changed, 38 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index ca8f74c3f0d..6d30caaae71 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Wed Oct 27 22:16:12 UTC 2010 Steve Huston <shuston@riverace.com>
+
+ * ace/INET_Addr.cpp (set): When looking up a hostname, always use
+ gethostbyname() for IPv4 requests, even if IPv6 is available.
+ getaddrinfo() (used when IPv4 and 6 are both available) is hugely
+ slower than gethostbyname() in large vlan environments. Note that
+ even though gethostbyname() can grok IPv6 on Linux, it can't
+ anywhere else, so I avoided trying to go that route.
+
Wed Oct 20 16:07:09 UTC 2010 Steve Huston <shuston@riverace.com>
* ace/Timer_Queue_Adapters.cpp (ACE_Thread_Timer_Queue_Adapter::svc):
diff --git a/ace/INET_Addr.cpp b/ace/INET_Addr.cpp
index 229dcaebf6e..f446db0030f 100644
--- a/ace/INET_Addr.cpp
+++ b/ace/INET_Addr.cpp
@@ -338,16 +338,20 @@ ACE_INET_Addr::set (u_short port_number,
sizeof this->inet_addr_);
#if defined (ACE_HAS_IPV6)
- struct addrinfo hints;
- struct addrinfo *res = 0;
- int error = 0;
- ACE_OS::memset (&hints, 0, sizeof (hints));
-# if defined (ACE_USES_IPV4_IPV6_MIGRATION)
- if (address_family == AF_UNSPEC && !ACE::ipv6_enabled())
+ // Let the IPv4 case fall through to the non-IPv6-capable section.
+ // We don't need the additional getaddrinfo() capability and the Linux
+ // getaddrinfo() is substantially slower than gethostbyname() w/
+ // large vlans.
+# if defined (ACE_USES_IPV4_IPV6_MIGRATION)
+ if (address_family == AF_UNSPEC && !ACE::ipv6_enabled ())
address_family = AF_INET;
-# endif /* ACE_USES_IPV4_IPV6_MIGRATION */
- if (address_family == AF_UNSPEC || address_family == AF_INET6)
+# endif /* ACE_USES_IPV4_IPV6_MIGRATION */
+ if (address_family != AF_INET)
{
+ struct addrinfo hints;
+ struct addrinfo *res = 0;
+ int error = 0;
+ ACE_OS::memset (&hints, 0, sizeof (hints));
hints.ai_family = AF_INET6;
error = ::getaddrinfo (host_name, 0, &hints, &res);
if (error)
@@ -359,35 +363,32 @@ ACE_INET_Addr::set (u_short port_number,
errno = error;
return -1;
}
- address_family = AF_INET;
- }
- }
- if (address_family == AF_INET)
- {
- hints.ai_family = AF_INET;
- error = ::getaddrinfo (host_name, 0, &hints, &res);
- if (error)
- {
- if (res)
- ::freeaddrinfo(res);
- errno = error;
- return -1;
+ // Let AF_UNSPEC try again w/ IPv4.
+ hints.ai_family = AF_INET;
+ error = ::getaddrinfo (host_name, 0, &hints, &res);
+ if (error)
+ {
+ if (res)
+ ::freeaddrinfo(res);
+ errno = error;
+ return -1;
+ }
}
+ this->set_type (res->ai_family);
+ this->set_addr (res->ai_addr, res->ai_addrlen);
+ this->set_port_number (port_number, encode);
+ ::freeaddrinfo (res);
+ return 0;
}
- this->set_type (res->ai_family);
- this->set_addr (res->ai_addr, res->ai_addrlen);
- this->set_port_number (port_number, encode);
- ::freeaddrinfo (res);
- return 0;
#else /* ACE_HAS_IPV6 */
// IPv6 not supported... insure the family is set to IPv4
address_family = AF_INET;
this->set_type (address_family);
this->inet_addr_.in4_.sin_family = static_cast<short> (address_family);
-#ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN
+# ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN
this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_);
-#endif
+# endif
struct in_addr addrv4;
if (ACE_OS::inet_aton (host_name,
&addrv4) == 1)