merge revision(s) 34413:

* lib/tempfile.rb (Tempfile#unlink, Tempfile::Remover#call): Just
	  call File.unlink and ignore ENOENT because existence check
	  before unlinking does not help in terms of race condition.

	* lib/tempfile.rb (Tempfile#unlink, Tempfile::Remover#call): My
	  comment about thread safeness is obsolete.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2012-02-12 07:54:28 +00:00
parent c9fac6977b
commit 66f39c771a
3 changed files with 27 additions and 17 deletions

View file

@ -1,3 +1,12 @@
Sun Feb 12 16:53:18 2012 Akinori MUSHA <knu@iDaemons.org>
* lib/tempfile.rb (Tempfile#unlink, Tempfile::Remover#call): Just
call File.unlink and ignore ENOENT because existence check
before unlinking does not help in terms of race condition.
* lib/tempfile.rb (Tempfile#unlink, Tempfile::Remover#call): My
comment about thread safeness is obsolete.
Sun Feb 12 16:50:28 2012 Akinori MUSHA <knu@iDaemons.org> Sun Feb 12 16:50:28 2012 Akinori MUSHA <knu@iDaemons.org>
* lib/shellwords.rb: Fix rdoc markups. * lib/shellwords.rb: Fix rdoc markups.

View file

@ -227,18 +227,17 @@ class Tempfile < DelegateClass(File)
# # to do so again. # # to do so again.
# end # end
def unlink def unlink
# keep this order for thread safeness
return unless @tmpname return unless @tmpname
begin begin
if File.exist?(@tmpname) File.unlink(@tmpname)
File.unlink(@tmpname) rescue Errno::ENOENT
end
# remove tmpname from remover
@data[0] = @data[1] = nil
@tmpname = nil
rescue Errno::EACCES rescue Errno::EACCES
# may not be able to unlink on Windows; just ignore # may not be able to unlink on Windows; just ignore
return
end end
# remove tmpname from remover
@data[0] = @data[1] = nil
@tmpname = nil
end end
alias delete unlink alias delete unlink
@ -270,20 +269,22 @@ class Tempfile < DelegateClass(File)
end end
def call(*args) def call(*args)
if @pid == $$ return if @pid != $$
path, tmpfile = *@data
STDERR.print "removing ", path, "..." if $DEBUG path, tmpfile = *@data
tmpfile.close if tmpfile STDERR.print "removing ", path, "..." if $DEBUG
# keep this order for thread safeness tmpfile.close if tmpfile
if path
File.unlink(path) if File.exist?(path) if path
begin
File.unlink(path)
rescue Errno::ENOENT
end end
STDERR.print "done\n" if $DEBUG
end end
STDERR.print "done\n" if $DEBUG
end end
end end
# :startdoc: # :startdoc:

View file

@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3" #define RUBY_VERSION "1.9.3"
#define RUBY_PATCHLEVEL 100 #define RUBY_PATCHLEVEL 101
#define RUBY_RELEASE_DATE "2012-02-12" #define RUBY_RELEASE_DATE "2012-02-12"
#define RUBY_RELEASE_YEAR 2012 #define RUBY_RELEASE_YEAR 2012