* lib/tempfile.rb (Tempfile#make_tmpname): removed thread race
condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c6c6ab873e
commit
c2a81f31ef
@ -1,3 +1,8 @@
|
|||||||
|
Sat Aug 29 03:11:29 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/tempfile.rb (Tempfile#make_tmpname): removed thread race
|
||||||
|
condition.
|
||||||
|
|
||||||
Fri Aug 28 20:29:34 2009 Akinori MUSHA <knu@iDaemons.org>
|
Fri Aug 28 20:29:34 2009 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* lib/tempfile.rb (Tempfile#callback): Debug information should be
|
* lib/tempfile.rb (Tempfile#callback): Debug information should be
|
||||||
|
@ -125,12 +125,8 @@ class Tempfile < DelegateClass(File)
|
|||||||
#
|
#
|
||||||
# === Exceptions
|
# === Exceptions
|
||||||
#
|
#
|
||||||
# Under rare circumstances, this constructor can raise an instance of
|
# If Tempfile.new cannot find a unique filename within a limited
|
||||||
# Tempfile::CreationError. This could happen if a large number
|
# number of tries, then it will raise an exception.
|
||||||
# of threads or processes are simultaneously trying to create temp files
|
|
||||||
# and stepping on each others' toes. If Tempfile.new cannot find
|
|
||||||
# a unique filename within a limited number of tries, then it will raise
|
|
||||||
# this exception.
|
|
||||||
def initialize(basename, *rest)
|
def initialize(basename, *rest)
|
||||||
# I wish keyword argument settled soon.
|
# I wish keyword argument settled soon.
|
||||||
if opts = Hash.try_convert(rest[-1])
|
if opts = Hash.try_convert(rest[-1])
|
||||||
@ -191,7 +187,8 @@ class Tempfile < DelegateClass(File)
|
|||||||
end
|
end
|
||||||
|
|
||||||
t = Time.now.strftime("%Y%m%d")
|
t = Time.now.strftime("%Y%m%d")
|
||||||
path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}-#{n}#{suffix}"
|
th = Thread.current.object_id
|
||||||
|
path = "#{prefix}#{t}-#{$$}-#{th.to_s(36)}-#{rand(0x100000000).to_s(36)}-#{n}#{suffix}"
|
||||||
end
|
end
|
||||||
private :make_tmpname
|
private :make_tmpname
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user