libstore: use non-blocking locks in createTempDirInStore

gc tryLocks first, then deletes. we can use the same order since there's
no sequence of operations that would let us lock our new directory *and*
have the gc delete it (except outright bugs). the worst possible outcome
is that we create a few directories that'll be deleted by a later gc run

Change-Id: I6d3524f4990f8deee10804e6fbb0d0a26f3d57fe
This commit is contained in:
eldritch horrors
2025-02-14 15:28:50 +00:00
parent 81275c9ad7
commit 65ee7f5da4
+1 -2
View File
@@ -1493,8 +1493,7 @@ std::pair<Path, AutoCloseFD> LocalStore::createTempDirInStore()
if (tmpDirFd.get() < 0) {
continue;
}
lockFile(tmpDirFd.get(), ltWrite);
lockedByUs = true;
lockedByUs = tryLockFile(tmpDirFd.get(), ltWrite);
} while (!pathExists(tmpDirFn) || !lockedByUs);
return {tmpDirFn, std::move(tmpDirFd)};
}