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:
@@ -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)};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user