-
-
Save headius/c6f7fd57de77a7199b27f6584f2ad5db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/src/main/java/org/jruby/RubyIO.java b/core/src/main/java/org/jruby/RubyIO.java | |
index 1f54e7e..aaa2bb9 100644 | |
--- a/core/src/main/java/org/jruby/RubyIO.java | |
+++ b/core/src/main/java/org/jruby/RubyIO.java | |
@@ -1754,10 +1754,18 @@ public class RubyIO extends RubyObject implements IOEncodable { | |
if (fptr.io_fflush(context) < 0) | |
throw runtime.newSystemCallError(""); | |
-// # ifndef _WIN32 /* already called in io_fflush() */ | |
-// if ((int)rb_thread_io_blocking_region(nogvl_fsync, fptr, fptr->fd) < 0) | |
-// rb_sys_fail_path(fptr->pathv); | |
-// # endif | |
+ if (!Platform.IS_WINDOWS) { /* already called in io_fflush() */ | |
+ try { | |
+ if (fptr.fileChannel() != null) fptr.fileChannel().force(true); | |
+ if (fptr.fd().chNative != null) { | |
+ int ret = runtime.getPosix().fsync(fptr.fd().chNative.getFD()); | |
+ if (ret < 0) throw runtime.newErrnoFromInt(runtime.getPosix().errno()); | |
+ } | |
+ } catch (IOException ioe) { | |
+ throw runtime.newIOErrorFromException(ioe); | |
+ } | |
+ } | |
+ | |
return RubyFixnum.zero(runtime); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment