about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-01-27T12·19+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-01-27T12·19+0000
commit59682e618805701f9c249736514df6db457895f9 (patch)
tree4a66762d4dffe3d37ed84c13bd0d2c314275b233 /src/libutil
parenta24b78e9f1a7326badb6c38d5d63aeb6ccdf9970 (diff)
* Make lock removal safe by signalling to blocked processes that the
  lock they are waiting on has become stale (we do this by writing a
  meaningless token to the unlinked file).

Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.cc9
-rw-r--r--src/libutil/util.hh1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index e77009321d..0af6ee149b 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -415,6 +415,15 @@ bool AutoCloseFD::isOpen()
 }
 
 
+/* Pass responsibility for closing this fd to the caller. */
+int AutoCloseFD::borrow()
+{
+    int oldFD = fd;
+    fd = -1;
+    return oldFD;
+}
+
+
 void Pipe::create()
 {
     int fds[2];
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index a79c07305d..d947c34252 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -184,6 +184,7 @@ public:
     operator int();
     void close();
     bool isOpen();
+    int borrow();
 };