diff options
author | Steve Huston <shuston@riverace.com> | 2010-10-27 22:24:33 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2010-10-27 22:24:33 +0000 |
commit | 5b5342fd5432bcacba299371087c2355c020665b (patch) | |
tree | 242f2fd3299d7487b9927c92df3eaf3b1e48c2a6 | |
parent | 596d4feb7390e6970b4c6e6cc9704ea3201a0bc9 (diff) | |
download | ATCD-5b5342fd5432bcacba299371087c2355c020665b.tar.gz |
ChangeLogTag:Wed Oct 27 22:16:12 UTC 2010 Steve Huston <shuston@riverace.com>
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ace/INET_Addr.cpp | 57 |
2 files changed, 38 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog index a1f3316783b..06a0a8cfbc0 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) |