diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-08-19 22:43:43 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-10-13 12:12:44 +0200 |
commit | ff453b06f94b4305694beac8255d9ff51bed1a63 (patch) | |
tree | 2bb76638bb02b9a2001b6d2b9a9cf76e3b57d3a6 /src/libstore/local-store.cc | |
parent | 8614cf13344eca75074cd4af20fd90238571b0b6 (diff) |
Fix auto-gc
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r-- | src/libstore/local-store.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index faecdb00b..0e6556e11 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -382,11 +382,16 @@ LocalStore::LocalStore(const Params & params) (select id from Realisations where drvPath = ? and outputName = ?)); )"); } +} + +AutoCloseFD LocalStore::openGCLock() +{ Path fnGCLock = stateDir + "/gc.lock"; - state->fdGCLock = open(fnGCLock.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0600); - if (!state->fdGCLock) + auto fdGCLock = open(fnGCLock.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0600); + if (!fdGCLock) throw SysError("opening global GC lock '%1%'", fnGCLock); + return fdGCLock; } @@ -1509,7 +1514,8 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair) /* Acquire the global GC lock to get a consistent snapshot of existing and valid paths. */ - FdLock gcLock(_state.lock()->fdGCLock.get(), ltWrite, true, "waiting for the big garbage collector lock..."); + auto fdGCLock = openGCLock(); + FdLock gcLock(fdGCLock.get(), ltRead, true, "waiting for the big garbage collector lock..."); StringSet store; for (auto & i : readDirectory(realStoreDir)) store.insert(i.name); |