[PATCH] D54599: [Profile] Avoid race condition when dumping GCDA files.
calixte via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 15 14:26:20 PST 2018
calixte added inline comments.
================
Comment at: lib/profile/GCDAProfiling.c:361
if (fd == -1) {
- /* Bah! It's hopeless. */
- int errnum = errno;
- fprintf(stderr, "profiling: %s: cannot open: %s\n", filename,
- strerror(errnum));
- return;
+ fd = open(filename, O_RDWR | O_BINARY);
+ if (fd == -1) {
----------------
vsk wrote:
> Why try to create the file again?
The first attempt (line 355) can fail because the parent directory is not here or because the file already exists.
So we create the parent dirs (if required) and then try again to create the file and if it fails again then the file exists and then get the fd with fd = open(filename, O_RDWR | O_BINARY) (which shouldn't return -1)
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D54599
More information about the llvm-commits
mailing list