Skip to content

Commit

Permalink
Fix compile on windows: O_SYNC is not available, use a my_sync() call…
Browse files Browse the repository at this point in the history
… instead.
  • Loading branch information
spetrunia committed Apr 13, 2018
1 parent 5545753 commit 78e4215
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion storage/rocksdb/rdb_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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
Expand Down

0 comments on commit 78e4215

Please sign in to comment.