Merge pull request #293 from ikerexxe/sync_file_write

commonio: force lock file sync
This commit is contained in:
Serge Hallyn 2020-11-08 16:36:36 -06:00 committed by GitHub
commit 599cc003da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,7 +157,17 @@ static int do_lock_file (const char *file, const char *lock, bool log)
if (write (fd, buf, (size_t) len) != len) {
if (log) {
(void) fprintf (stderr,
"%s: %s: %s\n",
"%s: %s file write error: %s\n",
Prog, file, strerror (errno));
}
(void) close (fd);
unlink (file);
return 0;
}
if (fdatasync (fd) == -1) {
if (log) {
(void) fprintf (stderr,
"%s: %s file sync error: %s\n",
Prog, file, strerror (errno));
}
(void) close (fd);