From 93a2800b2ea08fae92a738eeedd43580e1446c8d Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Fri, 17 Nov 2006 21:04:57 -0800 Subject: [PATCH] close all fcntl locks when a file descriptor for the file is closed (braindead interface) darcs-hash:20061118050457-0c629-03a0fa8190a6b5c94299903571df9a168980412c.gz --- src/org/ibex/nestedvm/Runtime.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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; -- 1.7.10.4