mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-18 22:54:25 +01:00
lightningd: use fsync not fdatasync.
Apparently MacOS doesn't always have fdatasync, so use fsync. Even more importantly check whether it succeeds! Fixes: #6516 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -504,7 +504,8 @@ static bool configfile_replace_var(struct lightningd *ld,
|
|||||||
contents = tal_strjoin(tmpctx, take(lines), "\n", STR_TRAIL);
|
contents = tal_strjoin(tmpctx, take(lines), "\n", STR_TRAIL);
|
||||||
if (!write_all(outfd, contents, strlen(contents)))
|
if (!write_all(outfd, contents, strlen(contents)))
|
||||||
fatal("Writing %s: %s", template, strerror(errno));
|
fatal("Writing %s: %s", template, strerror(errno));
|
||||||
fdatasync(outfd);
|
if (fsync(outfd) != 0)
|
||||||
|
fatal("Syncing %s: %s", template, strerror(errno));
|
||||||
|
|
||||||
if (rename(template, cv->file) != 0)
|
if (rename(template, cv->file) != 0)
|
||||||
fatal("Renaming %s over %s: %s",
|
fatal("Renaming %s over %s: %s",
|
||||||
|
|||||||
Reference in New Issue
Block a user