aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/gc.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-18 14:52:04 +0100
committereldritch horrors <pennae@lix.systems>2024-03-18 15:42:52 -0600
commitf38ae92a38a66b597dbd6975219d6ddb4f52fa4f (patch)
treebe6e1ed225e3d77a3c1fbcef1778169878326cbe /src/libstore/gc.cc
parent0f518f44e289114eb4828c8232bc0b79c7a85ac7 (diff)
libutil: make AutoCloseFD a better resource
add a reset() method to close the wrapped fd instead of assigning magic constants. also make the from-fd constructor explicit so you can't accidentally assign the *wrong* magic constant, or even an unrelated integer that also just happens to be an fd by pure chance. Change-Id: I51311b0f6e040240886b5103d39d1794a6acc325
Diffstat (limited to 'src/libstore/gc.cc')
-rw-r--r--src/libstore/gc.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index bd9be52f3..20519c1a2 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -549,7 +549,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
if (fds[1].revents) {
/* Accept a new connection. */
assert(fds[1].revents & POLLIN);
- AutoCloseFD fdClient = accept(fdServer.get(), nullptr, nullptr);
+ AutoCloseFD fdClient{accept(fdServer.get(), nullptr, nullptr)};
if (!fdClient) continue;
debug("GC roots server accepted new client");
@@ -647,7 +647,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
by another process. We need to be sure that we can acquire an
exclusive lock before deleting them. */
if (baseName.find("tmp-", 0) == 0) {
- AutoCloseFD tmpDirFd = open(realPath.c_str(), O_RDONLY | O_DIRECTORY);
+ AutoCloseFD tmpDirFd{open(realPath.c_str(), O_RDONLY | O_DIRECTORY)};
if (tmpDirFd.get() == -1 || !lockFile(tmpDirFd.get(), ltWrite, false)) {
debug("skipping locked tempdir '%s'", realPath);
return;