close all fcntl locks when a file descriptor for the file is closed (braindead interface)
authorDavid Crawshaw <david@zentus.com>
Sat, 18 Nov 2006 05:04:57 +0000 (21:04 -0800)
committerDavid Crawshaw <david@zentus.com>
Sat, 18 Nov 2006 05:04:57 +0000 (21:04 -0800)
darcs-hash:20061118050457-0c629-03a0fa8190a6b5c94299903571df9a168980412c.gz

src/org/ibex/nestedvm/Runtime.java

index 5c2cc6a..1b2e372 100644 (file)
@@ -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;
         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;
         fds[fdn].close();
         fds[fdn] = null;        
         return true;