Skip to content

Commit 49bd659

Browse files
author
fengyubiao
committed
try to fix the test
1 parent 09f6f69 commit 49bd659

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

native-io/src/main/native-io-jni/cpp/native_io_jni.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
#define _GNU_SOURCE
2222

23+
#include <jni.h>
24+
#include <io.h>
2325
#include <errno.h>
2426
#include <fcntl.h>
2527
#include <stdlib.h>
@@ -165,7 +167,14 @@ JNIEXPORT jint JNICALL
165167
Java_org_apache_bookkeeper_common_util_nativeio_NativeIOJni_fsync(JNIEnv * env,
166168
jclass clazz,
167169
jint fd) {
168-
int res = fsync(fd);
170+
int res;
171+
172+
// Guarantee compatibility for winsows.
173+
#ifdef _WIN32
174+
res = _commit((int)fd);
175+
#else
176+
res = fsync((int)fd);
177+
#endif
169178

170179
if (res == -1) {
171180
throwExceptionWithErrno(env, "Failed to fsync");

0 commit comments

Comments
 (0)