ruby-changes:58350
From: Jeremy <ko1@a...>
Date: Tue, 22 Oct 2019 04:49:01 +0900 (JST)
Subject: [ruby-changes:58350] f37cc1c719 (master): Fallback to TCP in resolv if UDP bind raises EACCES
https://git.ruby-lang.org/ruby.git/commit/?id=f37cc1c719 From f37cc1c719f12d2cad6032aa4e6f4236f0604992 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Sun, 7 Jul 2019 18:51:42 -0700 Subject: Fallback to TCP in resolv if UDP bind raises EACCES Original patch from Andy Grimm. Fixes [Bug #10747] diff --git a/lib/resolv.rb b/lib/resolv.rb index 2b81c05..3d401cc 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -514,10 +514,15 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L514 def fetch_resource(name, typeclass) lazy_initialize - requester = make_udp_requester + begin + requester = make_udp_requester + rescue Errno::EACCES + # fall back to TCP + end senders = {} begin @config.resolv(name) {|candidate, tout, nameserver, port| + requester ||= make_tcp_requester(nameserver, port) msg = Message.new msg.rd = 1 msg.add_question(candidate, typeclass) @@ -550,7 +555,7 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L555 end } ensure - requester.close + requester&.close end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/