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

ruby-changes:12957

From: nobu <ko1@a...>
Date: Sat, 29 Aug 2009 03:28:11 +0900 (JST)
Subject: [ruby-changes:12957] Ruby:r24699 (trunk): * lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition.

nobu	2009-08-29 03:27:30 +0900 (Sat, 29 Aug 2009)

  New Revision: 24699

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

  Log:
    * lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition.

  Modified files:
    trunk/ChangeLog
    trunk/lib/tmpdir.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24698)
+++ ChangeLog	(revision 24699)
@@ -1,8 +1,10 @@
-Sat Aug 29 03:11:29 2009  Nobuyoshi Nakada  <nobu@r...>
+Sat Aug 29 03:27:17 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/tempfile.rb (Tempfile#make_tmpname): removed thread race
 	  condition.
 
+	* lib/tmpdir.rb (Dir.mktmpdir): ditto.
+
 Fri Aug 28 20:29:34 2009  Akinori MUSHA  <knu@i...>
 
 	* lib/tempfile.rb (Tempfile#callback): Debug information should be
Index: lib/tmpdir.rb
===================================================================
--- lib/tmpdir.rb	(revision 24698)
+++ lib/tmpdir.rb	(revision 24699)
@@ -111,9 +111,10 @@
     end
     tmpdir ||= Dir.tmpdir
     t = Time.now.strftime("%Y%m%d")
+    th = Thread.current.object_id.to_s(36)
     n = nil
     begin
-      path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
+      path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{th}-#{rand(0x100000000).to_s(36)}"
       path << "-#{n}" if n
       path << suffix
       Dir.mkdir(path, 0700)

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

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