[
https://issues.apache.org/jira/browse/THRIFT-2539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14015294#comment-14015294
]
Randy Abernethy commented on THRIFT-2539:
-----------------------------------------
Looking around for a better implementation, perhaps this patch from the Apache
trunk provides guidance:
{code}
--- apr/apr/trunk/network_io/unix/sockaddr.c 2012/05/21 20:38:41 1341196
+++ apr/apr/trunk/network_io/unix/sockaddr.c 2012/05/28 13:01:04 1343233
@@ -364,8 +364,23 @@
}
error = getaddrinfo(hostname, servname, &hints, &ai_list);
#ifdef HAVE_GAI_ADDRCONFIG
- if (error == EAI_BADFLAGS && family == APR_UNSPEC) {
- /* Retry without AI_ADDRCONFIG if it was rejected. */
+ /*
+ * Using AI_ADDRCONFIG involves some unfortunate guesswork because it
+ * does not consider loopback addresses when trying to determine if
+ * IPv4 or IPv6 is configured on a system (see RFC 3493).
+ * This is a problem if one actually wants to listen on or connect to
+ * the loopback address of a protocol family that is not otherwise
+ * configured on the system. See PR 52709.
+ * To work around some of the problems, retry without AI_ADDRCONFIG
+ * in case of EAI_ADDRFAMILY.
+ * XXX: apr_sockaddr_info_get() should really accept a flag to determine
+ * XXX: if AI_ADDRCONFIG's guesswork is wanted and if the address is
+ * XXX: to be used for listen() or connect().
+ *
+ * In case of EAI_BADFLAGS, AI_ADDRCONFIG is not supported.
+ */
+ if ((family == APR_UNSPEC) && (error == EAI_BADFLAGS
+ || error == EAI_ADDRFAMILY)) {
hints.ai_flags &= ~AI_ADDRCONFIG;
error = getaddrinfo(hostname, servname, &hints, &ai_list);
}
{code}
> Tsocket.cpp addrinfo ai_flags = AI_ADDRCONFIG
> ---------------------------------------------
>
> Key: THRIFT-2539
> URL: https://issues.apache.org/jira/browse/THRIFT-2539
> Project: Thrift
> Issue Type: Question
> Affects Versions: 0.9.1
> Reporter: MichaĆ Gazda
> Assignee: Randy Abernethy
> Attachments: THRIFT-2539-my-new-feature.patch, TSocket.cpp
>
>
> While creating and using thrift based app we have found some problem on
> windows 7 which was not present on winxp. When we try to open socket with
> local_open() for the host name "localhost" getaddrinfo fails with 11004. What
> is important we do not have any physical network address as all network cards
> are disabled in the system. As I assume it is connected wit he flag
> AI_ADDRCONFIG. Why it is set by default? I wonder if I do remove it can it
> cause some problems? I would like our app to be able to communicate locally
> even if there is no external network available.
> Hope to get quick reply, thank you.
--
This message was sent by Atlassian JIRA
(v6.2#6252)