зеркало из https://github.com/github/ruby.git
* ext/socket/socket.c (sock_s_getaddrinfo): use family_to_int.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6e4149f04a
Коммит
e485a566ed
|
@ -1,3 +1,7 @@
|
|||
Thu Jan 1 20:47:09 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/socket.c (sock_s_getaddrinfo): use family_to_int.
|
||||
|
||||
Thu Jan 1 20:17:47 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/socket.c: include constants.h at top.
|
||||
|
|
|
@ -3252,14 +3252,10 @@ sock_s_getaddrinfo(int argc, VALUE *argv)
|
|||
hints.ai_family = FIX2INT(family);
|
||||
}
|
||||
else if ((ap = StringValuePtr(family)) != 0) {
|
||||
if (strcmp(ap, "AF_INET") == 0) {
|
||||
hints.ai_family = PF_INET;
|
||||
}
|
||||
#ifdef INET6
|
||||
else if (strcmp(ap, "AF_INET6") == 0) {
|
||||
hints.ai_family = PF_INET6;
|
||||
}
|
||||
#endif
|
||||
int af;
|
||||
if (family_to_int(ap, RSTRING_LEN(family), &af) == -1)
|
||||
rb_raise(rb_eSocket, "unknown socket domain %s", ap);
|
||||
hints.ai_family = af;
|
||||
}
|
||||
|
||||
if (!NIL_P(socktype)) {
|
||||
|
|
|
@ -110,4 +110,9 @@ class TestSocket < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(addr) }
|
||||
}
|
||||
end
|
||||
|
||||
def test_getaddrinfo
|
||||
# This should not send a DNS query because AF_UNIX.
|
||||
assert_raise(SocketError) { Socket.getaddrinfo("www.kame.net", 80, "AF_UNIX") }
|
||||
end
|
||||
end if defined?(Socket)
|
||||
|
|
Загрузка…
Ссылка в новой задаче