From d808918583d406d93c9007cf14a9f39af7e4b83e Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 21 Oct 2017 23:19:47 +0000 Subject: [PATCH] deprecate TCPSocket.gethostbyname. TCPSocket.gethostbyname has problems similar to Socket.gethostbyname. An example of the problem which only the address family of the first address is returned: ``` pp TCPSocket.gethostbyname("www.wide.ad.jp") #=> ["www.wide.ad.jp", [], 10, "2001:200:dff:fff1:216:3eff:fe4b:651c", "203.178.137.58"] ``` The address family of the first address, AF_INET6 (10), is returned but the address family of the second address, AF_INET, is not returned. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/socket/tcpsocket.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ext/socket/tcpsocket.c b/ext/socket/tcpsocket.c index a7a82fd880..012a8f5a64 100644 --- a/ext/socket/tcpsocket.c +++ b/ext/socket/tcpsocket.c @@ -41,7 +41,16 @@ tcp_sockaddr(struct sockaddr *addr, socklen_t len) * call-seq: * TCPSocket.gethostbyname(hostname) => [official_hostname, alias_hostnames, address_family, *address_list] * - * Lookups host information by _hostname_. + * Use Addrinfo.getaddrinfo instead. + * This method is deprecated since following reasons: + * + * - The 3rd element of result is the address family of the first address. + * The address families of rest addresses are not returned. + * - gethostbyname() is may take long time and it may block other threads. + * (GVL cannot be released since gethostbyname() is not thread safe.) + * - This method uses gethostbyname() function already removed from POSIX. + * + * This method lookups host information by _hostname_. * * TCPSocket.gethostbyname("localhost") * #=> ["localhost", ["hal"], 2, "127.0.0.1"]