From 2235d504b735a952a6067443bc927815ecbe4317 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 28 Aug 2009 18:27:30 +0000 Subject: [PATCH] * 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 --- ChangeLog | 4 +++- lib/tmpdir.rb | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5eef2f1cc7..6d42aa094c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,10 @@ -Sat Aug 29 03:11:29 2009 Nobuyoshi Nakada +Sat Aug 29 03:27:17 2009 Nobuyoshi Nakada * 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 * lib/tempfile.rb (Tempfile#callback): Debug information should be diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb index 0d247bdd54..1b137eeae3 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)