mirror of
https://github.com/wiiu-env/homebrew_on_menu_plugin.git
synced 2024-11-21 18:19:15 +01:00
Change the scope of the mutex when hooking into the FSReadfile to avoid a possible deadlook when exiting some games.
This commit is contained in:
parent
6d868eabb9
commit
b10a288150
22
src/main.cpp
22
src/main.cpp
@ -451,12 +451,14 @@ DECL_FUNCTION(int32_t, MCP_TitleList, uint32_t handle, uint32_t *outTitleCount,
|
||||
|
||||
uint32_t titleCount = *outTitleCount;
|
||||
|
||||
std::lock_guard<std::mutex> lock(fileInfosMutex);
|
||||
readCustomTitlesFromSD();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(fileInfosMutex);
|
||||
readCustomTitlesFromSD();
|
||||
|
||||
for (auto &gFileInfo : fileInfos) {
|
||||
memcpy(&(titleList[titleCount]), &(gFileInfo->titleInfo), sizeof(MCPTitleListType));
|
||||
titleCount++;
|
||||
for (auto &gFileInfo : fileInfos) {
|
||||
memcpy(&(titleList[titleCount]), &(gFileInfo->titleInfo), sizeof(MCPTitleListType));
|
||||
titleCount++;
|
||||
}
|
||||
}
|
||||
|
||||
*outTitleCount = titleCount;
|
||||
@ -540,10 +542,12 @@ DECL_FUNCTION(FSStatus, FSCloseFile, FSClient *client, FSCmdBlock *block, FSFile
|
||||
}
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSReadFile, FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, uint32_t flags) {
|
||||
const std::lock_guard<std::mutex> lock(fileReaderListMutex);
|
||||
for (auto &reader : openFileReaders) {
|
||||
if ((uint32_t) reader.get() == (uint32_t) handle) {
|
||||
return (FSStatus) (reader->read(buffer, size * count) / size);
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(fileReaderListMutex);
|
||||
for (auto &reader : openFileReaders) {
|
||||
if ((uint32_t) reader.get() == (uint32_t) handle) {
|
||||
return (FSStatus) (reader->read(buffer, size * count) / size);
|
||||
}
|
||||
}
|
||||
}
|
||||
FSStatus result = real_FSReadFile(client, block, buffer, size, count, handle, unk1, flags);
|
||||
|
Loading…
Reference in New Issue
Block a user