From: David Crawshaw Date: Sat, 18 Nov 2006 05:04:57 +0000 (-0800) Subject: close all fcntl locks when a file descriptor for the file is closed (braindead interface) X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=commitdiff_plain;h=93a2800b2ea08fae92a738eeedd43580e1446c8d close all fcntl locks when a file descriptor for the file is closed (braindead interface) darcs-hash:20061118050457-0c629-03a0fa8190a6b5c94299903571df9a168980412c.gz --- diff --git a/src/org/ibex/nestedvm/Runtime.java b/src/org/ibex/nestedvm/Runtime.java index 5c2cc6a..1b2e372 100644 --- a/src/org/ibex/nestedvm/Runtime.java +++ b/src/org/ibex/nestedvm/Runtime.java @@ -704,6 +704,20 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { if(state == EXITED || state == EXECED) throw new IllegalStateException("closeFD called in inappropriate state"); if(fdn < 0 || fdn >= OPEN_MAX) return false; if(fds[fdn] == null) return false; + + // release all fcntl locks on this file + Seekable s = fds[fdn].seekable(); + if (s != null) { + try { + for (int i=0; i < LOCK_MAX; i++) { + if (locks[i] != null && s.equals(locks[i].seekable())) { + locks[i].release(); + locks[i] = null; + } + } + } catch (IOException e) { throw new RuntimeException(e); } + } + fds[fdn].close(); fds[fdn] = null; return true;