# HG changeset patch # User xlu # Date 1231877323 28800 # Node ID 4db4e58c16bd5a55fcbd4be1eabf368c05537b67 # Parent a0401dc51d0b4fe9a92e76810936a41d2387ef9e 6791815: Fix for 6471657 can cause deadlock on non-Solaris platforms when initializing direct buffer support Summary: Place the state transition inside the loop so that the VMThread could proceed for safepoint Reviewed-by: dholmes, never, acorn diff -r a0401dc51d0b -r 4db4e58c16bd src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Thu Jan 08 16:27:28 2009 -0500 +++ b/src/share/vm/prims/jni.cpp Tue Jan 13 12:08:43 2009 -0800 @@ -2691,8 +2691,13 @@ directBufferSupportInitializeEnded = 1; } else { - ThreadInVMfromNative tivn(thread); // set state as yield_all can call os:sleep while (!directBufferSupportInitializeEnded && !directBufferSupportInitializeFailed) { + // Set state as yield_all can call os:sleep. On Solaris, yield_all calls + // os::sleep which requires the VM state transition. On other platforms, it + // is not necessary. The following call to change the VM state is purposely + // put inside the loop to avoid potential deadlock when multiple threads + // try to call this method. See 6791815 for more details. + ThreadInVMfromNative tivn(thread); os::yield_all(); } }