mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-21 02:09:05 +02:00
ZipFileReader: Lock the archive when looking up a file
Texture replacement looks up files from several IO threads at once, while another thread may be reading from the same archive. libzip isn't thread safe, and a name lookup writes to the archive: it caches each name's guessed encoding, and allocates a converted copy of CP437 names. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
0e396a99cb
commit
df40740ae0
1 file changed
+3
@@ -351,6 +351,9 @@ public:
|
||||
|
||||
VFSFileReference *ZipFileReader::GetFile(std::string_view path) {
|
||||
std::string p(path);
|
||||
// Texture replacement looks up files from several threads. libzip isn't thread safe, and the lookup
|
||||
// writes to the archive (it caches each name's encoding, and a converted copy for CP437 names).
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
// An exact match uses libzip's hash table, the case insensitive one compares every name in the zip.
|
||||
int zi = zip_name_locate(zip_file_, p.c_str(), 0);
|
||||
if (zi < 0) {
|
||||
|
||||
Reference in new issue
Block a user