Skip to content

Commit 881a0d9

Browse files
committed
Use JDK for File#flock on Windows
Windows does not use native file descriptors and does not properly bind a native `flock` function, so this logic should not be used on Windows. Forcing this logic to use the JDK equivalent flocking API appears to resolve issues with the Logger gem. Fixes jruby#8801
1 parent e50e94a commit 881a0d9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

core/src/main/java/org/jruby/util/io/PosixShim.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ public int flock(ChannelFD fd, int lockMode) {
216216

217217
int real_fd = fd.realFileno;
218218

219-
if (posix.isNative() && real_fd != -1 && real_fd < FilenoUtil.FIRST_FAKE_FD && !Platform.IS_SOLARIS) {
219+
if (!Platform.IS_SOLARIS && !Platform.IS_WINDOWS &&
220+
posix.isNative() && real_fd != -1 && real_fd < FilenoUtil.FIRST_FAKE_FD) {
220221
// we have a real fd and not on Solaris...try native flocking
221222
// see jruby/jruby#3254 and jnr/jnr-posix#60
222223
int result = posix.flock(real_fd, lockMode);

0 commit comments

Comments
 (0)