Skip to content

Commit

Permalink
Actually try to sync FS when IO.fsync is called. Fixes #4073.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Aug 24, 2016
1 parent 7df6090 commit 999cea0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions core/src/main/java/org/jruby/RubyIO.java
Expand Up @@ -1754,10 +1754,18 @@ public RubyFixnum fsync(ThreadContext context) {
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);
}

Expand Down

0 comments on commit 999cea0

Please sign in to comment.