mirror of https://github.com/PCSX2/pcsx2.git
IPC: avoid deadlocks
This commit is contained in:
parent
49dc994351
commit
a40e6ba693
|
@ -138,19 +138,7 @@ char* SocketIPC::MakeFailIPC(char* ret_buffer, uint32_t size = 5)
|
||||||
|
|
||||||
int SocketIPC::StartSocket()
|
int SocketIPC::StartSocket()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
// socket timeout
|
|
||||||
DWORD tv = 10 * 1000; // 10 seconds
|
|
||||||
#else
|
|
||||||
// socket timeout
|
|
||||||
struct timeval tv;
|
|
||||||
tv.tv_sec = 10;
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_msgsock = accept(m_sock, 0, 0);
|
m_msgsock = accept(m_sock, 0, 0);
|
||||||
setsockopt(m_msgsock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);
|
|
||||||
setsockopt(m_msgsock, SOL_SOCKET, SO_SNDTIMEO, (const char*)&tv, sizeof tv);
|
|
||||||
|
|
||||||
if (m_msgsock == -1)
|
if (m_msgsock == -1)
|
||||||
{
|
{
|
||||||
|
@ -225,10 +213,12 @@ void SocketIPC::ExecuteTaskInThread()
|
||||||
SocketIPC::IPCBuffer res;
|
SocketIPC::IPCBuffer res;
|
||||||
|
|
||||||
// we remove 4 bytes to get the message size out of the IPC command
|
// we remove 4 bytes to get the message size out of the IPC command
|
||||||
// size in ParseCommand
|
// size in ParseCommand.
|
||||||
if (receive_length == 0)
|
// also, if we got a failed command, let's reset the state so we don't
|
||||||
res = IPCBuffer{5, MakeFailIPC(m_ret_buffer)};
|
// end up deadlocking by getting out of sync, eg when a client
|
||||||
else
|
// disconnects
|
||||||
|
if (receive_length != 0)
|
||||||
|
{
|
||||||
res = ParseCommand(&m_ipc_buffer[4], m_ret_buffer, (u32)end_length - 4);
|
res = ParseCommand(&m_ipc_buffer[4], m_ret_buffer, (u32)end_length - 4);
|
||||||
|
|
||||||
// if we cannot send back our answer restart the socket
|
// if we cannot send back our answer restart the socket
|
||||||
|
@ -238,6 +228,7 @@ void SocketIPC::ExecuteTaskInThread()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue