[前][次][番号順一覧][スレッド一覧]

ruby-changes:46837

From: nobu <ko1@a...>
Date: Mon, 29 May 2017 15:53:10 +0900 (JST)
Subject: [ruby-changes:46837] nobu:r58952 (trunk): fix race condition

nobu	2017-05-29 15:53:05 +0900 (Mon, 29 May 2017)

  New Revision: 58952

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58952

  Log:
    fix race condition
    
    * spec/mspec/lib/mspec/helpers/fs.rb (Object#mkdir_p): fix race
      condition when multi_exec.

  Modified files:
    trunk/spec/mspec/lib/mspec/helpers/fs.rb
Index: spec/mspec/lib/mspec/helpers/fs.rb
===================================================================
--- spec/mspec/lib/mspec/helpers/fs.rb	(revision 58951)
+++ spec/mspec/lib/mspec/helpers/fs.rb	(revision 58952)
@@ -17,11 +17,18 @@ class Object https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/helpers/fs.rb#L17
     parts.each do |part|
       name = File.join name, part
 
-      if File.file? name
+      stat = File.stat name
+      if stat.file?
         raise ArgumentError, "path component of #{path} is a file"
       end
 
-      Dir.mkdir name unless File.directory? name
+      unless stat.directory?
+        begin
+          Dir.mkdir name
+        rescue Errno::EEXIST
+          raise unless File.directory? name
+        end
+      end
     end
   end
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]