summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--lib/resolv.rb9
2 files changed, 12 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 512b915c6a..4f45ac5b73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Oct 7 00:27:01 2009 Tanaka Akira <akr@fsij.org>
+
+ * lib/resolv.rb (Resolv::DNS.bind_random_port): bind to "::" for IPv6.
+ (Resolv::DNS::ConnectedUDP#initialize): specify is_ipv6 argument of
+ bind_random_port.
+ [ruby-core:25970]
+
Tue Oct 6 21:30:58 2009 Tanaka Akira <akr@fsij.org>
* io.c (io_reopen): avoid close if possible.
diff --git a/lib/resolv.rb b/lib/resolv.rb
index ed8859d3c4..265a4b7f0c 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -599,10 +599,10 @@ class Resolv
}
end
- def self.bind_random_port(udpsock) # :nodoc:
+ def self.bind_random_port(udpsock, is_ipv6=false) # :nodoc:
begin
port = rangerand(1024..65535)
- udpsock.bind("", port)
+ udpsock.bind(is_ipv6 ? "::" : "", port)
rescue Errno::EADDRINUSE
retry
end
@@ -699,8 +699,9 @@ class Resolv
super()
@host = host
@port = port
- @sock = UDPSocket.new(host.index(':') ? Socket::AF_INET6 : Socket::AF_INET)
- DNS.bind_random_port(@sock)
+ is_ipv6 = host.index(':')
+ @sock = UDPSocket.new(is_ipv6 ? Socket::AF_INET6 : Socket::AF_INET)
+ DNS.bind_random_port(@sock, is_ipv6)
@sock.connect(host, port)
@sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD
end