summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-06 03:31:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-06 03:31:46 +0000
commite667897b46f5a112b29b7cbcc1e095e72841b40d (patch)
treef83e5acf55c7b28508a509697516128a1d4eadc0
parente6c0a8f19e3f38fdc77906ea545f8d3b0479adf7 (diff)
resolv.rb: remove rangerand
* lib/resolv.rb (Resolv::DNS.rangerand): rand and random_number accept a Range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/resolv.rb14
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/resolv.rb b/lib/resolv.rb
index e296516..edca926 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -609,16 +609,6 @@ class Resolv
end
end
-
- def self.rangerand(range) # :nodoc:
- base = range.begin
- len = range.end - range.begin
- if !range.exclude_end?
- len += 1
- end
- base + random(len)
- end
-
RequestID = {} # :nodoc:
RequestIDMutex = Thread::Mutex.new # :nodoc:
@@ -627,7 +617,7 @@ class Resolv
RequestIDMutex.synchronize {
h = (RequestID[[host, port]] ||= {})
begin
- id = rangerand(0x0000..0xffff)
+ id = random(0x0000..0xffff)
end while h[id]
h[id] = true
}
@@ -648,7 +638,7 @@ class Resolv
def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc:
begin
- port = rangerand(1024..65535)
+ port = random(1024..65535)
udpsock.bind(bind_host, port)
rescue Errno::EADDRINUSE, # POSIX
Errno::EACCES, # SunOS: See PRIV_SYS_NFS in privileges(5)