From 272608a5fbe80865b626d693240821e714443d9e Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 22 Feb 2019 04:20:23 +0300 Subject: [PATCH] Use F_FULLFSYNC instead of fsync on Darwin. GitOrigin-RevId: 05a7bc0683641a679b026b6d636fa127fe104123 --- tdutils/td/utils/port/FileFd.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tdutils/td/utils/port/FileFd.cpp b/tdutils/td/utils/port/FileFd.cpp index 3e5dde2ea..d504039a5 100644 --- a/tdutils/td/utils/port/FileFd.cpp +++ b/tdutils/td/utils/port/FileFd.cpp @@ -468,7 +468,11 @@ Stat FileFd::stat() { Status FileFd::sync() { CHECK(!empty()); #if TD_PORT_POSIX +#if TD_DARWIN + if (fcntl(get_native_fd().fd(), F_FULLFSYNC) == -1) { +#else if (fsync(get_native_fd().fd()) != 0) { +#endif #elif TD_PORT_WINDOWS if (FlushFileBuffers(get_native_fd().fd()) == 0) { #endif