File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
native-io/src/main/native-io-jni/cpp Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 2020 */
2121#define _GNU_SOURCE
2222
23+ #include <jni.h>
2324#include <errno.h>
2425#include <fcntl.h>
2526#include <stdlib.h>
2627#include <string.h>
28+ #ifdef _WIN32
29+ #include <io.h>
30+ #else
2731#include <unistd.h>
32+ #endif
2833
2934#include <org_apache_bookkeeper_common_util_nativeio_NativeIOJni.h>
3035
@@ -165,7 +170,14 @@ JNIEXPORT jint JNICALL
165170Java_org_apache_bookkeeper_common_util_nativeio_NativeIOJni_fsync (JNIEnv * env ,
166171 jclass clazz ,
167172 jint fd ) {
168- int res = fsync (fd );
173+ int res ;
174+
175+ // Guarantee compatibility for winsows.
176+ #ifdef _WIN32
177+ res = _commit ((int )fd );
178+ #else
179+ res = fsync ((int )fd );
180+ #endif
169181
170182 if (res == -1 ) {
171183 throwExceptionWithErrno (env , "Failed to fsync" );
You can’t perform that action at this time.
0 commit comments