Skip to content

Commit 78e4215

Browse files
committed
Fix compile on windows: O_SYNC is not available, use a my_sync() call instead.
1 parent 5545753 commit 78e4215

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

storage/rocksdb/rdb_utils.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ bool rdb_check_rocksdb_corruption() {
358358

359359
void rdb_persist_corruption_marker() {
360360
const std::string &fileName(myrocks::rdb_corruption_marker_file_name());
361-
int fd = my_open(fileName.c_str(), O_CREAT | O_SYNC, MYF(MY_WME));
361+
/* O_SYNC is not supported on windows */
362+
int fd = my_open(fileName.c_str(), O_CREAT | IF_WIN(0, O_SYNC), MYF(MY_WME));
362363
if (fd < 0) {
363364
sql_print_error("RocksDB: Can't create file %s to mark rocksdb as "
364365
"corrupted.",
@@ -370,6 +371,12 @@ void rdb_persist_corruption_marker() {
370371
fileName.c_str());
371372
}
372373

374+
#ifdef _WIN32
375+
/* A replacement for O_SYNC flag above */
376+
if (fd >= 0)
377+
my_sync(fd, MYF(0));
378+
#endif
379+
373380
int ret = my_close(fd, MYF(MY_WME));
374381
if (ret) {
375382
// NO_LINT_DEBUG

0 commit comments

Comments
 (0)