You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 23:56:30 +09:00
Fixed shutdown iteration issue
This commit is contained in:
@@ -156,16 +156,23 @@ namespace Lidgren.Network
|
|||||||
LogDebug("Shutting down...");
|
LogDebug("Shutting down...");
|
||||||
|
|
||||||
// disconnect and make one final heartbeat
|
// disconnect and make one final heartbeat
|
||||||
|
var list = new List<NetConnection>(m_handshakes.Count + m_connections.Count);
|
||||||
lock (m_connections)
|
lock (m_connections)
|
||||||
{
|
{
|
||||||
foreach (NetConnection conn in m_connections)
|
foreach (var conn in m_connections)
|
||||||
conn.Shutdown(m_shutdownReason);
|
if (conn != null)
|
||||||
}
|
list.Add(conn);
|
||||||
|
|
||||||
lock (m_handshakes)
|
lock (m_handshakes)
|
||||||
{
|
{
|
||||||
foreach (NetConnection conn in m_handshakes.Values)
|
foreach (var hs in m_handshakes.Values)
|
||||||
conn.Shutdown(m_shutdownReason);
|
if (hs != null)
|
||||||
|
list.Add(hs);
|
||||||
|
|
||||||
|
// shut down connections
|
||||||
|
foreach (NetConnection conn in list)
|
||||||
|
conn.Shutdown(m_shutdownReason);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// one final heartbeat, will send stuff and do disconnect
|
// one final heartbeat, will send stuff and do disconnect
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ namespace UnitTests
|
|||||||
throw new Exception("Received error message!");
|
throw new Exception("Received error message!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Done");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user