sys_fs: Fix race in file stream API

This commit is contained in:
Eladash 2021-09-27 19:25:20 +03:00 committed by Elad Ashkenazi
parent 781c5a76d9
commit 2243e22630

View file

@ -3125,6 +3125,7 @@ error_code sys_fs_lsn_lock(ppu_thread&, u32 fd)
return CELL_OK;
}
std::lock_guard lock(file->mp->mutex);
file->lock.compare_and_swap(0, 1);
return CELL_OK;
}
@ -3140,7 +3141,14 @@ error_code sys_fs_lsn_unlock(ppu_thread&, u32 fd)
return CELL_EBADF;
}
// See sys_fs_lsn_lock
if (file->mp == &g_mp_sys_dev_hdd0 || file->mp->flags & lv2_mp_flag::strict_get_block_size)
{
return CELL_OK;
}
// Unlock unconditionally
std::lock_guard lock(file->mp->mutex);
file->lock.compare_and_swap(1, 0);
return CELL_OK;
}