From 65ee7f5da4db9fd0c4a519dd681a49ceb8b99f4c Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Tue, 11 Feb 2025 01:06:15 +0100 Subject: [PATCH] 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 --- lix/libstore/local-store.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lix/libstore/local-store.cc b/lix/libstore/local-store.cc index 3ce6c237d..66be6dc99 100644 --- a/lix/libstore/local-store.cc +++ b/lix/libstore/local-store.cc @@ -1493,8 +1493,7 @@ std::pair 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)}; }