Skip to content

Commit

Permalink
don't take double lock unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Lidgren committed Sep 7, 2015
1 parent 1d0ee47 commit c42b885
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Lidgren.Network/NetPeer.Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,19 @@ private void ExecutePeerShutdown()
foreach (var conn in m_connections)
if (conn != null)
list.Add(conn);
}

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);
}
lock (m_handshakes)
{
foreach (var hs in m_handshakes.Values)
if (hs != null && list.Contains(hs) == false)
list.Add(hs);
}

// shut down connections
foreach (NetConnection conn in list)
conn.Shutdown(m_shutdownReason);

FlushDelayedPackets();

// one final heartbeat, will send stuff and do disconnect
Expand Down

0 comments on commit c42b885

Please sign in to comment.