Bug 747393 - Avoid race condition creating directories in JarMaker. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 14 Jun 2012 08:14:53 +0200
changeset 96607 7625b37383fe
parent 96606 b30e903d23a0
child 96608 3f408698a03f
push id22924
push usermh@glandium.org
push date2012-06-14 06:16 +0000
treeherdermozilla-central@3f408698a03f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs747393
milestone16.0a1
Bug 747393 - Avoid race condition creating directories in JarMaker. r=ted
config/JarMaker.py
--- a/config/JarMaker.py
+++ b/config/JarMaker.py
@@ -285,18 +285,19 @@ class JarMaker(object):
 
     jarfile = os.path.join(jardir, jarfile)
     jf = None
     if self.outputFormat == 'jar':
       #jar
       jarfilepath = jarfile + '.jar'
       try:
         os.makedirs(os.path.dirname(jarfilepath))
-      except OSError:
-        pass
+      except OSError, error:
+        if error.errno != errno.EEXIST:
+          raise
       jf = ZipFile(jarfilepath, 'a', lock = True)
       outHelper = self.OutputHelper_jar(jf)
     else:
       outHelper = getattr(self, 'OutputHelper_' + self.outputFormat)(jarfile)
     register = {}
     # This loop exits on either
     # - the end of the jar.mn file
     # - an line in the jar.mn file that's not part of a jar section
@@ -418,17 +419,21 @@ class JarMaker(object):
       except OSError, e:
         if e.errno != errno.ENOENT:
           raise
       return open(out, 'wb')
     def ensureDirFor(self, name):
       out = os.path.join(self.basepath, name)
       outdir = os.path.dirname(out)
       if not os.path.isdir(outdir):
-        os.makedirs(outdir)
+        try:
+          os.makedirs(outdir)
+        except OSError, error:
+          if error.errno != errno.EEXIST:
+            raise
       return out
 
   class OutputHelper_symlink(OutputHelper_flat):
     '''Subclass of OutputHelper_flat that provides a helper for
     creating a symlink including creating the parent directories.
     '''
     def symlink(self, src, dest):
       out = self.ensureDirFor(dest)