diff options
Diffstat (limited to 'compiler-rt/lib/profile/GCDAProfiling.c')
| -rw-r--r-- | compiler-rt/lib/profile/GCDAProfiling.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c index 45fbd07e544..c1a9c38081c 100644 --- a/compiler-rt/lib/profile/GCDAProfiling.c +++ b/compiler-rt/lib/profile/GCDAProfiling.c @@ -294,6 +294,11 @@ void llvm_gcda_start_file(const char *orig_filename, const char version[4], } } + /* Try to flock the file to serialize concurrent processes writing out to the + * same GCDA. This can fail if the filesystem doesn't support it, but in that + * case we'll just carry on with the old racy behaviour and hope for the best. + */ + flock(fd, LOCK_EX); output_file = fdopen(fd, mode); /* Initialize the write buffer. */ @@ -493,6 +498,7 @@ void llvm_gcda_end_file() { } fclose(output_file); + flock(fd, LOCK_UN); output_file = NULL; write_buffer = NULL; } |

