summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuang-Ming Huang <huangming.huang@gmail.com>2017-03-31 13:35:24 -0500
committerHuang-Ming Huang <huangming.huang@gmail.com>2017-03-31 13:36:08 -0500
commitd0f1eadba9ae7c6b2f789eab7eb7543e94652670 (patch)
treeb2b8847050bf1fcdb6c5daa804d6be890f27aba2
parent6dd56850da60fde290f39d313397d11cbae47df2 (diff)
downloadATCD-d0f1eadba9ae7c6b2f789eab7eb7543e94652670.tar.gz
Another attempt to fix PR #382 #385
-rw-r--r--ACE/ace/INET_Addr.cpp3
-rw-r--r--ACE/tests/INET_Addr_Test.cpp19
2 files changed, 14 insertions, 8 deletions
diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp
index a9b3649142d..d3073c88257 100644
--- a/ACE/ace/INET_Addr.cpp
+++ b/ACE/ace/INET_Addr.cpp
@@ -371,6 +371,9 @@ ACE_INET_Addr::set (u_short port_number,
#endif /* ACE_HAS_IPV6 && ACE_USES_IPV4_IPV6_MIGRATION */
#ifdef ACE_HAS_IPV6
+ if (address_family == AF_UNSPEC && ACE::ipv6_enabled ())
+ address_family = AF_INET6;
+
if (address_family != AF_INET
&& ACE_OS::inet_pton (AF_INET6, host_name,
&this->inet_addr_.in6_.sin6_addr) == 1)
diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp
index 816c2eb2b7d..6b389470032 100644
--- a/ACE/tests/INET_Addr_Test.cpp
+++ b/ACE/tests/INET_Addr_Test.cpp
@@ -390,14 +390,17 @@ int run_main (int, ACE_TCHAR *[])
{
ACE_INET_Addr addr;
int old_type = addr.get_type();
- addr.set(12345, ACE_TEXT ("localhost"));
- if (addr.get_type() != old_type) {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("IPv6 set failed: before addr.set(12345), addr.type() = %d\n")
- ACE_TEXT (" after addr.set(12345), addr.type() = %d\n"),
- old_type,
- addr.get_type ()));
- status = 1;
+ if (addr.set(12345, ACE_TEXT ("localhost")) == 0) {
+ if (addr.get_type() != old_type) {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("IPv6 set failed: addr.set(12345, \"localhost\"), old addr.type() = %d, new addr_type()= %d\n"),
+ old_type,
+ addr.get_type ()));
+ status = 1;
+ }
+ }
+ else {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 set failed: addr.set(12345, \"localhost\") returns nonzero\n")));
}
}