mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
Add logging and error handling for file syncing
Add logging and error handling inside, and outside of FileCommit. Functions such as fsync, fdatasync will return error in case of hardware I/O errors, and ignoring this means it can silently continue through data corruption. (c.f. https://lwn.net/SubscriberLink/752063/12b232ab5039efbe/)
This commit is contained in:
@@ -49,7 +49,8 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data
|
||||
|
||||
// Serialize
|
||||
if (!SerializeDB(fileout, data)) return false;
|
||||
FileCommit(fileout.Get());
|
||||
if (!FileCommit(fileout.Get()))
|
||||
return error("%s: Failed to flush file %s", __func__, pathTmp.string());
|
||||
fileout.fclose();
|
||||
|
||||
// replace existing file, if any, with new file
|
||||
|
||||
Reference in New Issue
Block a user