Network: Add fast peer disconnection in case of network error/unreachable host
This commit is contained in:
parent
dc24ff33a4
commit
a4543b30c3
|
|
@ -1110,7 +1110,26 @@ namespace Nz
|
||||||
std::size_t sentLength = 0;
|
std::size_t sentLength = 0;
|
||||||
|
|
||||||
if (!m_socket.SendMultiple(currentPeer->GetAddress(), m_buffers.data(), m_bufferCount, &sentLength))
|
if (!m_socket.SendMultiple(currentPeer->GetAddress(), m_buffers.data(), m_bufferCount, &sentLength))
|
||||||
|
{
|
||||||
|
switch (m_socket.GetLastError())
|
||||||
|
{
|
||||||
|
case SocketError::NetworkError:
|
||||||
|
case SocketError::UnreachableHost:
|
||||||
|
{
|
||||||
|
if (!currentPeer->IsConnected())
|
||||||
|
{
|
||||||
|
//< Network is down or unreachable (ex: IPv6 address when not supported), fails peer connection immediately
|
||||||
|
NotifyDisconnect(currentPeer, event);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[fallthrough]];
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_totalSentData += sentLength;
|
m_totalSentData += sentLength;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue