* 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
This commit is contained in:
akr 2010-06-23 21:24:31 +00:00
Родитель 23af1d2a4b
Коммит f77d8722c2
2 изменённых файлов: 26 добавлений и 20 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Thu Jun 24 06:22:27 2010 Tanaka Akira <akr@fsij.org>
* 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 <nobu@ruby-lang.org>
* marshal.c (struct dump_arg, struct load_arg): merge taint and

Просмотреть файл

@ -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;
}