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.1 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,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 C109B1F453 for ; Wed, 6 Feb 2019 19:08:50 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4F9F9121DAB; Thu, 7 Feb 2019 04:08:47 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 314EB121D9A for ; Thu, 7 Feb 2019 04:08:45 +0900 (JST) Received: by filter0086p3las1.sendgrid.net with SMTP id filter0086p3las1-30071-5C5B30BB-11 2019-02-06 19:08:43.687501667 +0000 UTC m=+86626.932432010 Received: from herokuapp.com (ec2-54-80-77-200.compute-1.amazonaws.com [54.80.77.200]) by ismtpd0004p1iad2.sendgrid.net (SG) with ESMTP id ZPViBaOaROOgD_LicL64SA for ; Wed, 06 Feb 2019 19:08:43.567 +0000 (UTC) Date: Wed, 06 Feb 2019 19:08:45 +0000 (UTC) From: eregontp@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66895 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15553 X-Redmine-Issue-Author: Glass_saga X-Redmine-Sender: Eregon 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5Vb7sXDsP2On6ZNBDTYLiivz2uKiR86FVYGC OGn5WMiTAWXar6CC8qqR6NXtmTsfKgmG3RxwvCl0K1BD6yl0bdzqdR7wHDwOQczFQKni+UfrAn1GJd 8PUFIRO8yb0rqF/etL6/bta+RD9Ec7Bzfw8wxBr60VH/AwqywxZ3gGw0SA== X-ML-Name: ruby-core X-Mail-Count: 91441 Subject: [ruby-core:91441] [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 Eregon (Benoit Daloze). akr (Akira Tanaka) wrote: > I think timeout library is not effective for getaddrinfo method (without getaddrinfo_a). That was also my experience trying to use SIGVTALRM to interrupt getaddrinfo(3): it had no effect, the code ignores EINTR and only ends after 5 seconds (its default timeout I guess). ---------------------------------------- Feature #15553: Addrinfo.getaddrinfo supports timeout https://bugs.ruby-lang.org/issues/15553#change-76699 * 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/