file locking problem in Java_gnu_java_nio_VMChannel_lock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

Beginning with this ChangeLog entry (snipped):

2006-09-16  Casey Marshall  <csm@xxxxxxx>

	* gnu/java/nio/FileChannelImpl.java: moved from
	gnu/java/nio/channels/FileChannelImpl.java.
	* gnu/java/nio/channels/FileChannelImpl.java: removed.
	* native/jni/java-nio/gnu_java_nio_VMChannel.c
	(Java_gnu_java_nio_VMChannel_lock): new function.

there have been locking problems when starting eclipse (i386).

The reason is that the check for MAX_LONG in

	Java_gnu_java_nio_channels_FileChannelImpl_lock

has not been carried over to

	Java_gnu_java_nio_VMChannel_lock

so the MAX_LONG value is cast to (off_t) and becomes -1 on this
architecture. The attached patch fixes this case. It is still
not safe for len > signed 32 bit.

-Edwin

? DIFF
? LOG
? cscope.out
? lock.patch
? lib/.gdb_history
? lib/vmlogignore.idx
? lib/vmlogignore.str
? lib/vmlogignore.txt
? native/target/Makefile
? native/target/Makefile.in
? native/target/Linux/Makefile
? native/target/Linux/Makefile.in
? native/target/generic/Makefile
? native/target/generic/Makefile.in
? tools/jarsigner.sh
? tools/keytool.sh
Index: native/jni/java-nio/gnu_java_nio_VMChannel.c
===================================================================
RCS file: /sources/classpath/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c,v
retrieving revision 1.4
diff -u -p -r1.4 gnu_java_nio_VMChannel.c
--- native/jni/java-nio/gnu_java_nio_VMChannel.c	17 Sep 2006 22:49:52 -0000	1.4
+++ native/jni/java-nio/gnu_java_nio_VMChannel.c	10 Oct 2006 18:01:01 -0000
@@ -1582,7 +1582,11 @@ Java_gnu_java_nio_VMChannel_lock (JNIEnv
   struct flock fl;
 
   fl.l_start  = (off_t) pos;
-  fl.l_len    = (off_t) len;
+  /* Long.MAX_VALUE means lock everything possible starting at pos. */
+  if (len == 9223372036854775807LL)
+    fl.l_len = 0;
+  else
+    fl.l_len = (off_t) len;
   fl.l_pid    = getpid ();
   fl.l_type   = (shared ? F_RDLCK : F_WRLCK);
   fl.l_whence = SEEK_SET;

[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux