OpenGLDevice: Fix inverted cache file lock

This commit is contained in:
Stenzek 2024-12-10 13:17:06 +10:00
parent 1e839224e8
commit 0bb83f6fd7
No known key found for this signature in database
2 changed files with 3 additions and 3 deletions

View File

@ -2818,7 +2818,7 @@ static bool SetLock(int fd, bool lock, bool block, Error* error)
bool res;
for (;;)
{
res = (lockf(fd, lock ? (block ? F_TLOCK : F_LOCK) : F_ULOCK, 0) == 0);
res = (lockf(fd, lock ? (block ? F_LOCK : F_TLOCK) : F_ULOCK, 0) == 0);
if (!res && errno == EINTR)
continue;
else

View File

@ -767,7 +767,7 @@ bool OpenGLDevice::OpenPipelineCache(const std::string& path, Error* error)
#ifdef HAS_POSIX_FILE_LOCK
// Unix doesn't prevent concurrent write access, need to explicitly lock it.
FileSystem::POSIXLock fp_lock(fp.get(), true, error);
FileSystem::POSIXLock fp_lock(fp.get(), false, error);
if (!fp_lock.IsLocked())
{
Error::AddPrefix(error, "Failed to lock cache file: ");
@ -865,7 +865,7 @@ bool OpenGLDevice::CreatePipelineCache(const std::string& path, Error* error)
if (!m_pipeline_disk_cache_file || !FileSystem::FSeek64(m_pipeline_disk_cache_file, 0, SEEK_SET, error))
return false;
m_pipeline_disk_cache_file_lock = FileSystem::POSIXLock(m_pipeline_disk_cache_file, true, error);
m_pipeline_disk_cache_file_lock = FileSystem::POSIXLock(m_pipeline_disk_cache_file, false, error);
if (!m_pipeline_disk_cache_file_lock.IsLocked())
{
Error::AddPrefix(error, "Failed to lock cache file: ");