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.0 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 DEDDB1F453 for ; Wed, 23 Jan 2019 21:47:42 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 682E5121241; Thu, 24 Jan 2019 06:47:40 +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 371F712117A for ; Thu, 24 Jan 2019 06:47:38 +0900 (JST) Received: by filter0080p3mdw1.sendgrid.net with SMTP id filter0080p3mdw1-6613-5C48E0F2-2F 2019-01-23 21:47:30.660056295 +0000 UTC m=+761945.902865754 Received: from herokuapp.com (ec2-54-211-52-65.compute-1.amazonaws.com [54.211.52.65]) by ismtpd0036p1mdw1.sendgrid.net (SG) with ESMTP id F5IjKuAdRZ-Z-s_1059Odg for ; Wed, 23 Jan 2019 21:47:30.529 +0000 (UTC) Date: Wed, 23 Jan 2019 21:47:32 +0000 (UTC) From: glass.saga@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66685 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15553 X-Redmine-Issue-Author: Glass_saga X-Redmine-Sender: Glass_saga 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5IWh65f760mgB+vJL94uiz23SwlR5nsjPAN4 bjh4qB0nPFkMe/zGJuzzVQuiQMpg0U3KOiKg26p9JX7XDJ2aZTaowc6bBi2HDVJ2qI6VRIxQX8dLXW dgQB3jiki0DkiP/TBkBfOeI4ro3LlCmZtR8FKWi5LR2GePYyDl/XG8pFgw== X-ML-Name: ruby-core X-Mail-Count: 91236 Subject: [ruby-core:91236] [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 Glass_saga (Masaki Matsushita). > Why hrtime.h is included? It's unnecessary. I'll remove it. ---------------------------------------- Feature #15553: Addrinfo.getaddrinfo supports timeout https://bugs.ruby-lang.org/issues/15553#change-76481 * 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/