Fallback to TCP in resolv if UDP bind raises EACCES
Original patch from Andy Grimm. Fixes [Bug #10747]
This commit is contained in:
parent
62d4382877
commit
f37cc1c719
Notes:
git
2019-10-22 04:49:05 +09:00
@ -514,10 +514,15 @@ class Resolv
|
|||||||
|
|
||||||
def fetch_resource(name, typeclass)
|
def fetch_resource(name, typeclass)
|
||||||
lazy_initialize
|
lazy_initialize
|
||||||
requester = make_udp_requester
|
begin
|
||||||
|
requester = make_udp_requester
|
||||||
|
rescue Errno::EACCES
|
||||||
|
# fall back to TCP
|
||||||
|
end
|
||||||
senders = {}
|
senders = {}
|
||||||
begin
|
begin
|
||||||
@config.resolv(name) {|candidate, tout, nameserver, port|
|
@config.resolv(name) {|candidate, tout, nameserver, port|
|
||||||
|
requester ||= make_tcp_requester(nameserver, port)
|
||||||
msg = Message.new
|
msg = Message.new
|
||||||
msg.rd = 1
|
msg.rd = 1
|
||||||
msg.add_question(candidate, typeclass)
|
msg.add_question(candidate, typeclass)
|
||||||
@ -550,7 +555,7 @@ class Resolv
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
requester.close
|
requester&.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user