[前][次][番号順一覧][スレッド一覧]

ruby-changes:48205

From: akr <ko1@a...>
Date: Sun, 22 Oct 2017 08:19:53 +0900 (JST)
Subject: [ruby-changes:48205] akr:r60319 (trunk): deprecate TCPSocket.gethostbyname.

akr	2017-10-22 08:19:47 +0900 (Sun, 22 Oct 2017)

  New Revision: 60319

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60319

  Log:
    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.

  Modified files:
    trunk/ext/socket/tcpsocket.c
Index: ext/socket/tcpsocket.c
===================================================================
--- ext/socket/tcpsocket.c	(revision 60318)
+++ ext/socket/tcpsocket.c	(revision 60319)
@@ -41,7 +41,16 @@ tcp_sockaddr(struct sockaddr *addr, sock https://github.com/ruby/ruby/blob/trunk/ext/socket/tcpsocket.c#L41
  * 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"]

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]