mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Fix possible data race when committing block files
It was recently pointed out to me that calling fsync() or fdatasync() on a new file is not sufficient to ensure it's persisted to disk, a the existence of the file itself is stored in the directory inode. This means that ensuring that a new file is actually committed also requires an fsync() on the parent directory. This change ensures that we call fsync() on the blocks directory after committing new block files.
This commit is contained in:
parent
220bb16cbe
commit
4574904038
1 changed files with 1 additions and 0 deletions
|
@ -92,6 +92,7 @@ bool FlatFileSeq::Flush(const FlatFilePos& pos, bool finalize)
|
|||
fclose(file);
|
||||
return error("%s: failed to commit file %d", __func__, pos.nFile);
|
||||
}
|
||||
DirectoryCommit(m_dir);
|
||||
|
||||
fclose(file);
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue