From 77da941bdea548a822fe282a6b20f82ea7fd3912 Mon Sep 17 00:00:00 2001 From: alanb Date: Thu, 13 Mar 2008 19:29:41 +0000 Subject: [PATCH] 6628575: (fc) lock/tryLock methods do not work with NFS servers that limit lock range to max file size Reviewed-by: sherman --- src/solaris/native/sun/nio/ch/FileChannelImpl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/solaris/native/sun/nio/ch/FileChannelImpl.c b/src/solaris/native/sun/nio/ch/FileChannelImpl.c index 897ad488e..6110143de 100644 --- a/src/solaris/native/sun/nio/ch/FileChannelImpl.c +++ b/src/solaris/native/sun/nio/ch/FileChannelImpl.c @@ -31,6 +31,7 @@ #include #include "sun_nio_ch_FileChannelImpl.h" #include "java_lang_Integer.h" +#include "java_lang_Long.h" #include "nio.h" #include "nio_util.h" #include @@ -291,7 +292,11 @@ Java_sun_nio_ch_FileChannelImpl_lock0(JNIEnv *env, jobject this, jobject fdo, struct flock64 fl; fl.l_whence = SEEK_SET; - fl.l_len = (off64_t)size; + if (size == (jlong)java_lang_Long_MAX_VALUE) { + fl.l_len = (off64_t)0; + } else { + fl.l_len = (off64_t)size; + } fl.l_start = (off64_t)pos; if (shared == JNI_TRUE) { fl.l_type = F_RDLCK; @@ -325,7 +330,11 @@ Java_sun_nio_ch_FileChannelImpl_release0(JNIEnv *env, jobject this, int cmd = F_SETLK64; fl.l_whence = SEEK_SET; - fl.l_len = (off64_t)size; + if (size == (jlong)java_lang_Long_MAX_VALUE) { + fl.l_len = (off64_t)0; + } else { + fl.l_len = (off64_t)size; + } fl.l_start = (off64_t)pos; fl.l_type = F_UNLCK; lockResult = fcntl(fd, cmd, &fl); -- GitLab