changeset 45:7b28e857d36c

6628575: (fc) lock/tryLock methods do not work with NFS servers that limit lock range to max file size Reviewed-by: sherman
author alanb
date Thu, 13 Mar 2008 19:29:41 +0000
parents c97ff189e490
children c73cb47fe250
files src/solaris/native/sun/nio/ch/FileChannelImpl.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/sun/nio/ch/FileChannelImpl.c	Tue Mar 11 14:49:53 2008 +0000
+++ b/src/solaris/native/sun/nio/ch/FileChannelImpl.c	Thu Mar 13 19:29:41 2008 +0000
@@ -31,6 +31,7 @@
 #include <sys/stat.h>
 #include "sun_nio_ch_FileChannelImpl.h"
 #include "java_lang_Integer.h"
+#include "java_lang_Long.h"
 #include "nio.h"
 #include "nio_util.h"
 #include <dlfcn.h>
@@ -291,7 +292,11 @@
     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 @@
     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);