diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-31T10·27+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-31T10·27+0000 |
commit | 1328aa33077fd1cf84869e366c82b8ea1d1abb5d (patch) | |
tree | 8f079aabcfb9d1d5b485170e0edb583c052039ee /src/libutil | |
parent | a7668411a10c79ad40c9c18caf2570d5c9f52182 (diff) |
* Start of concurrent garbage collection. Processes write temporary
roots to a per-process temporary file in /nix/var/nix/temproots while holding a write lock on that file. The garbage collector acquires read locks on all those files, thus blocking further progress in other Nix processes, and reads the sets of temporary roots.
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/util.cc | 13 | ||||
-rw-r--r-- | src/libutil/util.hh | 3 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 0af6ee149bae..611567c12b1b 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -234,8 +234,8 @@ Path createTempDir() void writeStringToFile(const Path & path, const string & s) { - AutoCloseFD fd = open(path.c_str(), - O_CREAT | O_EXCL | O_WRONLY, 0666); + AutoCloseFD fd(open(path.c_str(), + O_CREAT | O_EXCL | O_WRONLY, 0666)); if (fd == -1) throw SysError(format("creating file `%1%'") % path); writeFull(fd, (unsigned char *) s.c_str(), s.size()); @@ -375,6 +375,12 @@ AutoCloseFD::AutoCloseFD(int fd) } +AutoCloseFD::AutoCloseFD(const AutoCloseFD & fd) +{ + abort(); +} + + AutoCloseFD::~AutoCloseFD() { try { @@ -392,7 +398,7 @@ void AutoCloseFD::operator =(int fd) } -AutoCloseFD::operator int() +AutoCloseFD::operator int() const { return fd; } @@ -401,6 +407,7 @@ AutoCloseFD::operator int() void AutoCloseFD::close() { if (fd != -1) { + debug(format("closing fd %1%") % fd); if (::close(fd) == -1) /* This should never happen. */ throw SysError("closing file descriptor"); diff --git a/src/libutil/util.hh b/src/libutil/util.hh index d947c34252a7..104e3f2651b4 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -179,9 +179,10 @@ class AutoCloseFD public: AutoCloseFD(); AutoCloseFD(int fd); + AutoCloseFD(const AutoCloseFD & fd); ~AutoCloseFD(); void operator =(int fd); - operator int(); + operator int() const; void close(); bool isOpen(); int borrow(); |