summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-28 18:27:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-28 18:27:30 +0000
commitce5dfe6cff8d9c1a7222804b3d9978a448ba2c03 (patch)
tree155365ed5578eb91bde4859e661259e69b88f224
parent968c99c80e26fc18786fcf619dea54bc6cf1215f (diff)
downloadruby-ce5dfe6cff8d9c1a7222804b3d9978a448ba2c03.tar.gz
ruby-ce5dfe6cff8d9c1a7222804b3d9978a448ba2c03.tar.xz
ruby-ce5dfe6cff8d9c1a7222804b3d9978a448ba2c03.zip
* lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--lib/tmpdir.rb3
2 files changed, 5 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5eef2f1cc..6d42aa094 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,10 @@
-Sat Aug 29 03:11:29 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Aug 29 03:27:17 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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@iDaemons.org>
* lib/tempfile.rb (Tempfile#callback): Debug information should be
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 0d247bdd5..1b137eeae 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -111,9 +111,10 @@ class Dir
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)