From f77d8722c2d7728e0e57c59751a373cba464efab Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 23 Jun 2010 21:24:31 +0000 Subject: [PATCH] * ext/socket/raddrinfo.c (ruby_getaddrinfo__darwin): the workaround for Mac OS X moved from rsock_getaddrinfo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/socket/raddrinfo.c | 41 +++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c72915478..f3b53c2305 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jun 24 06:22:27 2010 Tanaka Akira + + * ext/socket/raddrinfo.c (ruby_getaddrinfo__darwin): the workaround + for Mac OS X moved from rsock_getaddrinfo. + Thu Jun 24 05:44:27 2010 Nobuyoshi Nakada * marshal.c (struct dump_arg, struct load_arg): merge taint and diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index 99426ed371..4bc20c913e 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -100,11 +100,11 @@ ruby_getnameinfo__aix(const struct sockaddr *sa, size_t salen, static int str_is_number(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) { + /* fix [ruby-core:29427] */ const char *tmp_servname; struct addrinfo tmp_hints; tmp_servname = servname; @@ -118,6 +118,26 @@ ruby_getaddrinfo__darwin(const char *nodename, const char *servname, } } int error = getaddrinfo(nodename, tmp_servname, &tmp_hints, res); + + if (error == 0) + { + /* [ruby-dev:23164] */ + struct addrinfo *r; + r = *res; + while (r) { + if (! r->ai_socktype) r->ai_socktype = hints->ai_socktype; + if (! r->ai_protocol) { + if (r->ai_socktype == SOCK_DGRAM) { + r->ai_protocol = IPPROTO_UDP; + } + else if (r->ai_socktype == SOCK_STREAM) { + r->ai_protocol = IPPROTO_TCP; + } + } + r = r->ai_next; + } + } + return error; } #undef getaddrinfo @@ -342,25 +362,6 @@ rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_h rsock_raise_socket_error("getaddrinfo", error); } -#if defined(__APPLE__) && defined(__MACH__) - /* [ruby-dev:23164] */ - { - struct addrinfo *r; - r = res; - while (r) { - if (! r->ai_socktype) r->ai_socktype = hints->ai_socktype; - if (! r->ai_protocol) { - if (r->ai_socktype == SOCK_DGRAM) { - r->ai_protocol = IPPROTO_UDP; - } - else if (r->ai_socktype == SOCK_STREAM) { - r->ai_protocol = IPPROTO_TCP; - } - } - r = r->ai_next; - } - } -#endif return res; }