diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-31 10:27:25 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-31 10:27:25 +0000 |
commit | 1328aa33077fd1cf84869e366c82b8ea1d1abb5d (patch) | |
tree | 8f079aabcfb9d1d5b485170e0edb583c052039ee /src/libutil/util.cc | |
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/util.cc')
-rw-r--r-- | src/libutil/util.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 0af6ee149..611567c12 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"); |