diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-08-28 18:27:30 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-08-28 18:27:30 +0000 |
| commit | ce5dfe6cff8d9c1a7222804b3d9978a448ba2c03 (patch) | |
| tree | 155365ed5578eb91bde4859e661259e69b88f224 /lib | |
| parent | 968c99c80e26fc18786fcf619dea54bc6cf1215f (diff) | |
| download | ruby-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
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/tmpdir.rb | 3 |
1 files changed, 2 insertions, 1 deletions
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) |
