OSDN Git Service

<rdar://problem/13551789> Fix yet another race in unique_file.
authorDouglas Gregor <dgregor@apple.com>
Fri, 5 Apr 2013 20:48:36 +0000 (20:48 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 5 Apr 2013 20:48:36 +0000 (20:48 +0000)
If the directory that will contain the unique file doesn't exist when
we tried to create the file, but another process creates it before we
get a chance to try creating it, we would bail out rather than try to
create the unique file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178908 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Unix/PathV2.inc

index a3dfd4b..7e0aead 100644 (file)
@@ -430,9 +430,7 @@ rety_open_create:
     if (SavedErrno == errc::file_exists)
       goto retry_random_path;
     // If path prefix doesn't exist, try to create it.
-    if (SavedErrno == errc::no_such_file_or_directory &&
-        !exists(path::parent_path(RandomPath)) &&
-        !TriedToCreateParent) {
+    if (SavedErrno == errc::no_such_file_or_directory && !TriedToCreateParent) {
       TriedToCreateParent = true;
       StringRef p(RandomPath);
       SmallString<64> dir_to_create;