1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-16 07:06:30 +09:00

Fixed shutdown iteration issue

This commit is contained in:
lidgren
2011-03-10 18:45:18 +00:00
parent f4831a98a7
commit 97a2b76856
2 changed files with 16 additions and 8 deletions

View File

@@ -156,16 +156,23 @@ namespace Lidgren.Network
LogDebug("Shutting down...");
// disconnect and make one final heartbeat
var list = new List<NetConnection>(m_handshakes.Count + m_connections.Count);
lock (m_connections)
{
foreach (NetConnection conn in m_connections)
conn.Shutdown(m_shutdownReason);
}
foreach (var conn in m_connections)
if (conn != null)
list.Add(conn);
lock (m_handshakes)
{
foreach (NetConnection conn in m_handshakes.Values)
conn.Shutdown(m_shutdownReason);
lock (m_handshakes)
{
foreach (var hs in m_handshakes.Values)
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