FileFd::sync_barrier uses F_BARRIERFSYNC on darwin

This commit is contained in:
Arseny Smirnov 2023-02-10 12:17:22 +01:00
parent 80fc0346e8
commit a0dd1e1a07
2 changed files with 11 additions and 0 deletions

View File

@ -635,6 +635,16 @@ Status FileFd::sync() {
return Status::OK();
}
Status FileFd::sync_barrier() {
CHECK(!empty());
#if TD_DARWIN && defined(F_BARRIERFSYNC)
if (detail::skip_eintr([&] { return fcntl(get_native_fd().fd(), F_BARRIERFSYNC); }) == -1) {
return Status::OK();
}
#endif
return sync();
}
Status FileFd::seek(int64 position) {
CHECK(!empty());
#if TD_PORT_POSIX

View File

@ -62,6 +62,7 @@ class FileFd {
Result<Stat> stat() const;
Status sync() TD_WARN_UNUSED_RESULT;
Status sync_barrier() TD_WARN_UNUSED_RESULT;
Status seek(int64 position) TD_WARN_UNUSED_RESULT;