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=-4.1 required=3.0 tests=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 A9D9020248 for ; Wed, 3 Apr 2019 10:40:17 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id E5582120BCB; Wed, 3 Apr 2019 19:40:12 +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 663C8120EBB for ; Wed, 3 Apr 2019 19:40:09 +0900 (JST) Received: by filter0016p3iad2.sendgrid.net with SMTP id filter0016p3iad2-20089-5CA48D88-2 2019-04-03 10:40:08.038557087 +0000 UTC m=+456865.703610183 Received: from herokuapp.com (unknown [54.85.62.139]) by ismtpd0045p1mdw1.sendgrid.net (SG) with ESMTP id kqQM-cpAQh6R5ho_fRQCUA for ; Wed, 03 Apr 2019 10:40:07.921 +0000 (UTC) Date: Wed, 03 Apr 2019 10:40:08 +0000 (UTC) From: maciej@mensfeld.pl Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67610 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15553 X-Redmine-Issue-Author: Glass_saga X-Redmine-Sender: maciej.mensfeld 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: =?us-ascii?Q?1UVFNop+J46xJRgKT91tQd4fJmTtITnXW0zIvVfv30DcQxgs5yuxjP+UZx7T4Y?= =?us-ascii?Q?exTPZvLBYVdLOOxmS5cqmpKXC0gNxSOO=2FamB3I+?= =?us-ascii?Q?JFtu1lehJl1CQk9irX8tjh5TzQ6=2FNI7QveKnsHh?= =?us-ascii?Q?xDa4qvDiFqN=2F3MA6sEZmmm8vE51akau+AKLoy96?= =?us-ascii?Q?XbJl3dqamN1yQctdC31qC5wV7zDyLPczz6Q=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92126 Subject: [ruby-core:92126] [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 maciej.mensfeld (Maciej Mensfeld). This is also related to it: https://bugs.ruby-lang.org/issues/14997 - once the DNS timeout is in place (when available) I could give the #14997 a shot adding per ip timeout and including the resolving timeout in the overall timeout. ---------------------------------------- Feature #15553: Addrinfo.getaddrinfo supports timeout https://bugs.ruby-lang.org/issues/15553#change-77452 * 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) patch2.diff (11.6 KB) -- https://bugs.ruby-lang.org/