From f5867ab7178784bc63a3deafcf4fb09260e4d19a Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 31 Dec 2012 23:31:56 +0000 Subject: Go ahead and get rid of the old page size interface and convert all the users over to the new one. No sense maintaining this "compatibility" layer it seems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171331 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Unix/PathV2.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/Support/Unix/PathV2.inc') diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index 453267046a..25712a8a9f 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -575,7 +575,7 @@ const char *mapped_file_region::const_data() const { } int mapped_file_region::alignment() { - return Process::GetPageSize(); + return process::get_self()->page_size(); } error_code detail::directory_iterator_construct(detail::DirIterState &it, -- cgit v1.2.3-18-g5258 From 06c7008e30d3e278f2d779135ff2ce50bfc643fc Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 10 Jan 2013 01:58:46 +0000 Subject: Fix a race condition in llvm::sys::path::unique_file: when we end up failing to create the unique file because the path doesn't exist, don't fail if someone else manages to create the path before we do. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172032 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Unix/PathV2.inc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/Support/Unix/PathV2.inc') diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index 25712a8a9f..741f44a9db 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -421,11 +421,12 @@ retry_random_path: rety_open_create: int RandomFD = ::open(RandomPath.c_str(), O_RDWR | O_CREAT | O_EXCL, mode); if (RandomFD == -1) { + int SavedErrno = errno; // If the file existed, try again, otherwise, error. - if (errno == errc::file_exists) + if (SavedErrno == errc::file_exists) goto retry_random_path; // If path prefix doesn't exist, try to create it. - if (errno == errc::no_such_file_or_directory && + if (SavedErrno == errc::no_such_file_or_directory && !exists(path::parent_path(RandomPath))) { StringRef p(RandomPath); SmallString<64> dir_to_create; @@ -440,13 +441,15 @@ rety_open_create: (*i)[1] == '/' && (*i)[2] != '/') return make_error_code(errc::no_such_file_or_directory); - if (::mkdir(dir_to_create.c_str(), 0700) == -1) + if (::mkdir(dir_to_create.c_str(), 0700) == -1 && + errno != errc::file_exists) return error_code(errno, system_category()); } } goto rety_open_create; } - return error_code(errno, system_category()); + + return error_code(SavedErrno, system_category()); } // Make the path absolute. -- cgit v1.2.3-18-g5258 From 2b9a946f981963c226eaafe1dd8fb8801b87d411 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 28 Feb 2013 00:38:19 +0000 Subject: [PathV2] In llvm::sys::fs::unique_file, make sure it doesn't fall into an infinite loop by constantly trying to create the parent path. This can happen if the path is a relative filename and the current directory was removed. Thanks to Daniel D. for the hint in fixing it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176226 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Unix/PathV2.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/Support/Unix/PathV2.inc') diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index 741f44a9db..44b31b3202 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -417,6 +417,10 @@ retry_random_path: RandomPath[i] = "0123456789abcdef"[sys::Process::GetRandomNumber() & 15]; } + // Make sure we don't fall into an infinite loop by constantly trying + // to create the parent path. + bool TriedToCreateParent = false; + // Try to open + create the file. rety_open_create: int RandomFD = ::open(RandomPath.c_str(), O_RDWR | O_CREAT | O_EXCL, mode); @@ -427,7 +431,9 @@ rety_open_create: 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))) { + !exists(path::parent_path(RandomPath)) && + !TriedToCreateParent) { + TriedToCreateParent = true; StringRef p(RandomPath); SmallString<64> dir_to_create; for (path::const_iterator i = path::begin(p), -- cgit v1.2.3-18-g5258