ruby-changes:22520
From: knu <ko1@a...>
Date: Mon, 13 Feb 2012 09:20:40 +0900 (JST)
Subject: [ruby-changes:22520] knu:r34572 (ruby_1_9_3): merge revision(s) 34413:
knu 2012-02-12 16:54:28 +0900 (Sun, 12 Feb 2012) New Revision: 34572 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34572 Log: 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. Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/lib/tempfile.rb branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 34571) +++ ruby_1_9_3/ChangeLog (revision 34572) @@ -1,3 +1,12 @@ +Sun Feb 12 16:53:18 2012 Akinori MUSHA <knu@i...> + + * 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@i...> * lib/shellwords.rb: Fix rdoc markups. Index: ruby_1_9_3/lib/tempfile.rb =================================================================== --- ruby_1_9_3/lib/tempfile.rb (revision 34571) +++ ruby_1_9_3/lib/tempfile.rb (revision 34572) @@ -227,18 +227,17 @@ # # to do so again. # end def unlink - # keep this order for thread safeness return unless @tmpname begin - if File.exist?(@tmpname) - File.unlink(@tmpname) - end - # remove tmpname from remover - @data[0] = @data[1] = nil - @tmpname = nil + File.unlink(@tmpname) + rescue Errno::ENOENT rescue Errno::EACCES # may not be able to unlink on Windows; just ignore + return end + # remove tmpname from remover + @data[0] = @data[1] = nil + @tmpname = nil end alias delete unlink @@ -270,20 +269,22 @@ end def call(*args) - if @pid == $$ - path, tmpfile = *@data + return if @pid != $$ - 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 - if path - File.unlink(path) if File.exist?(path) + tmpfile.close if tmpfile + + if path + begin + File.unlink(path) + rescue Errno::ENOENT end + end - STDERR.print "done\n" if $DEBUG - end + STDERR.print "done\n" if $DEBUG end end # :startdoc: Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 34571) +++ ruby_1_9_3/version.h (revision 34572) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 100 +#define RUBY_PATCHLEVEL 101 #define RUBY_RELEASE_DATE "2012-02-12" #define RUBY_RELEASE_YEAR 2012 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/