summaryrefslogtreecommitdiff
path: root/ext/socket/raddrinfo.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-23 12:25:07 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-23 12:25:07 +0000
commitacb8b3f7a99cd692da469e8ee729a6b6ec11c85d (patch)
tree72696fd824ed7cd4b5ca93adfbf73bcceb7d5647 /ext/socket/raddrinfo.c
parent80684e9c09338adcbbf1bc4827938f28178e84c1 (diff)
* ext/socket/raddrinfo.c (ruby_getaddrinfo__darwin): new workaround for
getaddrinfo problem on Mac OS X Snow Leopard. [ruby-core:29427] patch by Wataru Kimura. [ruby-core:30842] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/raddrinfo.c')
-rw-r--r--ext/socket/raddrinfo.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index 5478d1006c9..204588f7a04 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -97,6 +97,33 @@ ruby_getnameinfo__aix(const struct sockaddr *sa, size_t salen,
ruby_getnameinfo__aix((sa), (salen), (host), (hostlen), (serv), (servlen), (flags))
#endif
+static int str_isnumber __P((const char *));
+
+#if defined(__APPLE__)
+/* fix [ruby-core:29427] */
+static int
+ruby_getaddrinfo__darwin(const char *nodename, const char *servname,
+ struct addrinfo *hints, struct addrinfo **res)
+{
+ const char *tmp_servname;
+ struct addrinfo tmp_hints;
+ tmp_servname = servname;
+ MEMCPY(&tmp_hints, hints, struct addrinfo, 1);
+ if (nodename && servname) {
+ if (str_isnumber(tmp_servname) && atoi(servname) == 0) {
+ tmp_servname = NULL;
+#ifdef AI_NUMERICSERV
+ if (tmp_hints.ai_flags) tmp_hints.ai_flags &= ~AI_NUMERICSERV;
+#endif
+ }
+ }
+ int error = getaddrinfo(nodename, tmp_servname, &tmp_hints, res);
+ return error;
+}
+#undef getaddrinfo
+#define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo__darwin((node),(serv),(hints),(res))
+#endif
+
#ifndef GETADDRINFO_EMU
struct getaddrinfo_arg
{