From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id A67791F453 for ; Wed, 6 Feb 2019 12:45:06 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 3DDB5121633; Wed, 6 Feb 2019 21:45:03 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 8624C121637 for ; Wed, 6 Feb 2019 21:44:53 +0900 (JST) Received: by filter0045p3las1.sendgrid.net with SMTP id filter0045p3las1-13468-5C5AD6C4-2 2019-02-06 12:44:52.113396464 +0000 UTC m=+64334.298973213 Received: from herokuapp.com (ec2-54-80-77-200.compute-1.amazonaws.com [54.80.77.200]) by ismtpd0040p1mdw1.sendgrid.net (SG) with ESMTP id TuoA9kIyQM6qQiV0VQXUmQ for ; Wed, 06 Feb 2019 12:44:52.049 +0000 (UTC) Date: Wed, 06 Feb 2019 12:44:52 +0000 (UTC) From: akr@fsij.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66880 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15553 X-Redmine-Issue-Author: Glass_saga X-Redmine-Sender: akr X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7XxS/5/zDZREJcBL2aZGuFAHH56fLw5S++pN Y8fNuSIwCDIeLqexc9o0krqQsmKR07SKzTTLyiqHumocaJPsGuyrdqe89cN5OhXKcliv9aj/YoWzDO hOGuLArPrTUII48tXp8nb6Qld1hzrzcadb85 X-ML-Name: ruby-core X-Mail-Count: 91426 Subject: [ruby-core:91426] [Ruby trunk Feature#15553] Addrinfo.getaddrinfo supports timeout X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15553 has been updated by akr (Akira Tanaka). I think timeout library is not effective for getaddrinfo method (without getaddrinfo_a). What the patch tries to change on a platform which has no getaddrinfo_a? ---------------------------------------- Feature #15553: Addrinfo.getaddrinfo supports timeout https://bugs.ruby-lang.org/issues/15553#change-76685 * Author: Glass_saga (Masaki Matsushita) * Status: Open * Priority: Normal * Assignee: * Target version: 2.7 ---------------------------------------- Currently, we use Timeout in Net::HTTP and other standard libraries. lib/net/http.rb ``` 945 s = Timeout.timeout(@open_timeout, Net::OpenTimeout) { 946 begin 947 TCPSocket.open(conn_address, conn_port, @local_host, @local_port) 948 rescue => e 949 raise e, "Failed to open TCP connection to " + 950 "#{conn_address}:#{conn_port} (#{e.message})" 951 end 952 } ``` Socket.tcp supports connect_timeout, but Addrinfo.getaddrinfo doesn't support timeout. We need to use Timeout to wait name resolution. In this patch, Addrinfo.getaddrinfo support timeout and Socket.tcp accepts resolv_timeout. It uses getaddrinfo_a(3) if available, otherwise it uses Timeout. We can avoid thread creation to make a TCP connection if getaddrinfo_a(3) is available. ---Files-------------------------------- patch.diff (13.2 KB) -- https://bugs.ruby-lang.org/