mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-26 15:49:50 -06:00
Thread safe enq_reply.
This commit is contained in:
@ -83,6 +83,7 @@ IWII_IPC_HLE_Device* es_handles[ES_MAX_COUNT];
|
|||||||
typedef std::deque<u32> ipc_msg_queue;
|
typedef std::deque<u32> ipc_msg_queue;
|
||||||
static ipc_msg_queue request_queue; // ppc -> arm
|
static ipc_msg_queue request_queue; // ppc -> arm
|
||||||
static ipc_msg_queue reply_queue; // arm -> ppc
|
static ipc_msg_queue reply_queue; // arm -> ppc
|
||||||
|
static std::mutex s_reply_queue;
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
@ -159,7 +160,12 @@ void Reset(bool _bHard)
|
|||||||
g_DeviceMap.erase(g_DeviceMap.begin(), g_DeviceMap.end());
|
g_DeviceMap.erase(g_DeviceMap.begin(), g_DeviceMap.end());
|
||||||
}
|
}
|
||||||
request_queue.clear();
|
request_queue.clear();
|
||||||
reply_queue.clear();
|
|
||||||
|
// lock due to using reply_queue
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(s_reply_queue);
|
||||||
|
reply_queue.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown()
|
void Shutdown()
|
||||||
@ -241,6 +247,8 @@ IWII_IPC_HLE_Device* CreateFileIO(u32 _DeviceID, const std::string& _rDeviceName
|
|||||||
|
|
||||||
void DoState(PointerWrap &p)
|
void DoState(PointerWrap &p)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(s_reply_queue);
|
||||||
|
|
||||||
p.Do(request_queue);
|
p.Do(request_queue);
|
||||||
p.Do(reply_queue);
|
p.Do(reply_queue);
|
||||||
|
|
||||||
@ -536,6 +544,7 @@ void EnqRequest(u32 _Address)
|
|||||||
// Called when IOS module has some reply
|
// Called when IOS module has some reply
|
||||||
void EnqReply(u32 _Address)
|
void EnqReply(u32 _Address)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(s_reply_queue);
|
||||||
reply_queue.push_back(_Address);
|
reply_queue.push_back(_Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,12 +569,16 @@ void Update()
|
|||||||
Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HLE, LogTypes::LDEBUG);
|
Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HLE, LogTypes::LDEBUG);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply_queue.size())
|
// lock due to using reply_queue
|
||||||
{
|
{
|
||||||
WII_IPCInterface::GenerateReply(reply_queue.front());
|
std::lock_guard<std::mutex> lk(s_reply_queue);
|
||||||
INFO_LOG(WII_IPC_HLE, "<<-- Reply to IPC Request @ 0x%08x", reply_queue.front());
|
if (reply_queue.size())
|
||||||
reply_queue.pop_front();
|
{
|
||||||
|
WII_IPCInterface::GenerateReply(reply_queue.front());
|
||||||
|
INFO_LOG(WII_IPC_HLE, "<<-- Reply to IPC Request @ 0x%08x", reply_queue.front());
|
||||||
|
reply_queue.pop_front();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user