diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-04-20 11:21:08 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-04-23 14:25:28 +0200 |
commit | cf0277928fa8d955d75f661021845789194dfff7 (patch) | |
tree | da392672c936ad9f6a91c2d77c4377a22ac127d4 /src/addrdb.cpp | |
parent | 8b262eb2d80bfa27ae8501078ce47bc1407e9c55 (diff) |
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/)
Diffstat (limited to 'src/addrdb.cpp')
-rw-r--r-- | src/addrdb.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/addrdb.cpp b/src/addrdb.cpp index e4620e63c6..59305ff187 100644 --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -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 |