aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--lib/securerandom.rb4
2 files changed, 6 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 72557a12ec..8e2b7bf304 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Aug 31 14:07:11 2013 Tanaka Akira <akr@fsij.org>
+
+ * lib/securerandom.rb (random_bytes): Use Process.clock_gettime.
+
Sat Aug 31 00:25:15 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/encoding.h (rb_{ascii8bit,utf8,usascii}_encindex): get
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index cc33a08044..b1603b4ca9 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -54,8 +54,8 @@ module SecureRandom
@pid = 0 unless defined?(@pid)
pid = $$
unless @pid == pid
- now = Time.now
- ary = [now.to_i, now.nsec, @pid, pid]
+ now = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
+ ary = [now, @pid, pid]
OpenSSL::Random.random_add(ary.join("").to_s, 0.0)
@pid = pid
end