[前][次][番号順一覧][スレッド一覧]

ruby-changes:30661

From: akr <ko1@a...>
Date: Sat, 31 Aug 2013 14:08:04 +0900 (JST)
Subject: [ruby-changes:30661] akr:r42740 (trunk): * lib/securerandom.rb (random_bytes): Use Process.clock_gettime.

akr	2013-08-31 14:07:56 +0900 (Sat, 31 Aug 2013)

  New Revision: 42740

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42740

  Log:
    * lib/securerandom.rb (random_bytes): Use Process.clock_gettime.

  Modified files:
    trunk/ChangeLog
    trunk/lib/securerandom.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42739)
+++ ChangeLog	(revision 42740)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Aug 31 14:07:11 2013  Tanaka Akira  <akr@f...>
+
+	* lib/securerandom.rb (random_bytes): Use Process.clock_gettime.
+
 Sat Aug 31 00:25:15 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* include/ruby/encoding.h (rb_{ascii8bit,utf8,usascii}_encindex): get
Index: lib/securerandom.rb
===================================================================
--- lib/securerandom.rb	(revision 42739)
+++ lib/securerandom.rb	(revision 42740)
@@ -54,8 +54,8 @@ module SecureRandom https://github.com/ruby/ruby/blob/trunk/lib/securerandom.rb#L54
       @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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]