summaryrefslogtreecommitdiff
path: root/ext/socket/raddrinfo.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-23 21:24:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-23 21:24:31 +0000
commitf77d8722c2d7728e0e57c59751a373cba464efab (patch)
treee280d7f8e70b8bacba406c6c7473e46fe28272ed /ext/socket/raddrinfo.c
parent23af1d2a4bd3dd09de1b82e0bc216fcd4d148b41 (diff)
* 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
Diffstat (limited to 'ext/socket/raddrinfo.c')
-rw-r--r--ext/socket/raddrinfo.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index 99426ed..4bc20c9 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;
}