Summary: mkdir race prevents concurrent compiling with DMD
                    using make -j
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: patch
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Leandro Lucarella <> 2010-06-27 07:10:43 
PDT ---
Since DMD creates directories as needed, when using make -j to compile some
modules concurrently, if 2 modules lives in the same directory, that directory
doesn't exist and both are compiled at the same time, there are times where
this set of steps are performed:

1) dmd m1.d checks if dstdir exist (it doesn't)
2) dmd m2.d checks if dstdir exist (it doesn't)
3) dmd m1.d creates dstdir successfully
4) dmd m2.d tries to create dstdir but it fails because dmd m1.d already
created it.

Here is a simple patch. Created against D1 svn but I guess it will apply to D2
cleanly also.

diff --git a/src/root/root.c b/src/root/root.c
index 3d491a4..9df951c 100644
--- a/src/root/root.c
+++ b/src/root/root.c
@@ -957,7 +957,10 @@ void FileName::ensurePathExists(const char *path)
 #if POSIX
                 if (mkdir(path, 0777))
-                    error("cannot create directory %s", path);
+                {
+                    if (errno != EEXIST)
+                        error("cannot create directory %s", path);
+                }

I'm not sure how the mkdir() API for windows behaves regarding errno, I
couldn't find any reference of mkdir() for windows.

Adding a strerror() to the error message could be useful too.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to