mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
80684e9c09
commit
acb8b3f7a9
3 changed files with 42 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Jun 23 21:17:32 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* 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]
|
||||
|
||||
Wed Jun 23 17:12:27 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* NEWS (ptr): new method and deprecated methods. [ruby-dev:41681]
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -60,6 +60,15 @@ class TestSocket < Test::Unit::TestCase
|
|||
assert_raise(SocketError) { Socket.getaddrinfo("www.kame.net", 80, "AF_UNIX") }
|
||||
end
|
||||
|
||||
def test_getaddrinfo_raises_no_errors_on_port_argument_of_0 # [ruby-core:29427]
|
||||
assert_nothing_raised('[ruby-core:29427]'){ Socket.getaddrinfo('localhost', 0, Socket::AF_INET, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) }
|
||||
assert_nothing_raised('[ruby-core:29427]'){ Socket.getaddrinfo('localhost', '0', Socket::AF_INET, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) }
|
||||
assert_nothing_raised('[ruby-core:29427]'){ Socket.getaddrinfo('localhost', '00', Socket::AF_INET, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) }
|
||||
assert_raise(SocketError, '[ruby-core:29427]'){ Socket.getaddrinfo(nil, nil, Socket::AF_INET, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) }
|
||||
assert_nothing_raised('[ruby-core:29427]'){ TCPServer.open('localhost', 0) {} }
|
||||
end
|
||||
|
||||
|
||||
def test_getnameinfo
|
||||
assert_raise(SocketError) { Socket.getnameinfo(["AF_UNIX", 80, "0.0.0.0"]) }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue