1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-08-28 18:27:30 +00:00
parent f6bed84425
commit 2235d504b7
2 changed files with 5 additions and 2 deletions

View file

@ -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

View file

@ -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)