Mercurial > hg > release > icedtea-web-1.1
changeset 172:466ad8570145
Allow plugin and javaws to run concurrently, while maintaining locks on systems that only support exclusive locks.
author | Andrew Su <asu@redhat.com> |
---|---|
date | Thu, 17 Mar 2011 15:19:39 -0400 |
parents | 4e68f6f489cd |
children | a640b4e4d226 |
files | ChangeLog netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java |
diffstat | 2 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Mar 17 15:10:32 2011 -0400 +++ b/ChangeLog Thu Mar 17 15:19:39 2011 -0400 @@ -1,3 +1,9 @@ +2011-03-14 Andrew Su <asu@redhat.com> + + * netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: + (markNetxRunning): Handle case for when shared locks are not allowed + on the system. + 2011-03-14 Andrew Su <asu@redhat.com> * netx/net/sourceforge/jnlp/Launcher.java:
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java Thu Mar 17 15:10:32 2011 -0400 +++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java Thu Mar 17 15:19:39 2011 -0400 @@ -656,14 +656,21 @@ FileInputStream is = new FileInputStream(netxRunningFile); FileChannel channel = is.getChannel(); - fileLock = channel.lock(0, Long.MAX_VALUE, true); + fileLock = channel.lock(0, 1, true); + if (!fileLock.isShared()){ // We know shared locks aren't offered on this system. + FileLock temp = null; + for (long pos = 1; temp == null && pos < Long.MAX_VALUE - 1; pos++){ + temp = channel.tryLock(pos, 1, false); // No point in requesting for shared lock. + } + fileLock.release(); // We can release now, since we hold another lock. + fileLock = temp; // Keep the new lock so we can release later. + } + if (fileLock != null && fileLock.isShared()) { if (JNLPRuntime.isDebug()) { System.out.println("Acquired shared lock on " + netxRunningFile.toString() + " to indicate javaws is running"); } - } else { - fileLock = null; } } catch (IOException e) { e.printStackTrace();