mirror of https://github.com/PCSX2/pcsx2.git
DEV9: Fix race-condition while handling closed connection
This commit is contained in:
parent
f317ba327c
commit
f91f39afcd
|
@ -37,10 +37,10 @@ public:
|
||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Remove(Key key)
|
bool Remove(Key key)
|
||||||
{
|
{
|
||||||
std::unique_lock modifyLock(accessMutex);
|
std::unique_lock modifyLock(accessMutex);
|
||||||
map.erase(key);
|
return map.erase(key) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear()
|
void Clear()
|
||||||
|
|
|
@ -527,7 +527,8 @@ int SocketAdapter::SendFromConnection(ConnectionKey Key, IP_Packet* ipPkt)
|
||||||
void SocketAdapter::HandleConnectionClosed(BaseSession* sender)
|
void SocketAdapter::HandleConnectionClosed(BaseSession* sender)
|
||||||
{
|
{
|
||||||
const ConnectionKey key = sender->key;
|
const ConnectionKey key = sender->key;
|
||||||
connections.Remove(key);
|
if (!connections.Remove(key))
|
||||||
|
return;
|
||||||
|
|
||||||
// Defer deleting the connection untill we have left the calling session's callstack
|
// Defer deleting the connection untill we have left the calling session's callstack
|
||||||
if (std::this_thread::get_id() == sendThreadId)
|
if (std::this_thread::get_id() == sendThreadId)
|
||||||
|
@ -558,7 +559,8 @@ void SocketAdapter::HandleConnectionClosed(BaseSession* sender)
|
||||||
void SocketAdapter::HandleFixedPortClosed(BaseSession* sender)
|
void SocketAdapter::HandleFixedPortClosed(BaseSession* sender)
|
||||||
{
|
{
|
||||||
const ConnectionKey key = sender->key;
|
const ConnectionKey key = sender->key;
|
||||||
connections.Remove(key);
|
if (!connections.Remove(key))
|
||||||
|
return;
|
||||||
fixedUDPPorts.Remove(key.ps2Port);
|
fixedUDPPorts.Remove(key.ps2Port);
|
||||||
|
|
||||||
// Defer deleting the connection untill we have left the calling session's callstack
|
// Defer deleting the connection untill we have left the calling session's callstack
|
||||||
|
|
Loading…
Reference in New Issue