aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java13
2 files changed, 16 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e2c11d..6c7f59e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2011-03-14 Andrew Su <[email protected]>
+ * 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 <[email protected]>
+
* netx/net/sourceforge/jnlp/Launcher.java:
(fileLock): Removed private static field.
(launch): Mark NetX as running before launching apps.
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
index 02b6381..98bb6f5 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
@@ -656,14 +656,21 @@ public class JNLPRuntime {
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();