[Commits] 78e4215: Fix compile on windows: O_SYNC is not available, use a my_sync() call instead.

Sergei Petrunia psergey at askmonty.org
Fri Apr 13 20:26:40 EEST 2018


revision-id: 78e42153b51d6166b916a5bdb39e8726913c263e
parent(s): 5545753b0b21b98fbdd2d8b894bc141d1ed558b3
committer: Sergei Petrunia
branch nick: 10.2-r10
timestamp: 2018-04-13 20:26:40 +0300
message:

Fix compile on windows: O_SYNC is not available, use a my_sync() call instead.

---
 storage/rocksdb/rdb_utils.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/storage/rocksdb/rdb_utils.cc b/storage/rocksdb/rdb_utils.cc
index 19469d0..723e079 100644
--- a/storage/rocksdb/rdb_utils.cc
+++ b/storage/rocksdb/rdb_utils.cc
@@ -358,7 +358,8 @@ bool rdb_check_rocksdb_corruption() {
 
 void rdb_persist_corruption_marker() {
   const std::string &fileName(myrocks::rdb_corruption_marker_file_name());
-  int fd = my_open(fileName.c_str(), O_CREAT | O_SYNC, MYF(MY_WME));
+  /* O_SYNC is not supported on windows */
+  int fd = my_open(fileName.c_str(), O_CREAT | IF_WIN(0, O_SYNC), MYF(MY_WME));
   if (fd < 0) {
     sql_print_error("RocksDB: Can't create file %s to mark rocksdb as "
                     "corrupted.",
@@ -370,6 +371,12 @@ void rdb_persist_corruption_marker() {
                           fileName.c_str());
   }
 
+#ifdef _WIN32
+  /* A replacement for O_SYNC flag above */
+  if (fd >= 0)
+    my_sync(fd, MYF(0));
+#endif
+
   int ret = my_close(fd, MYF(MY_WME));
   if (ret) {
     // NO_LINT_DEBUG


More information about the commits mailing list