Commit 5a317587 authored by Marc Gravell's avatar Marc Gravell

As per discussion in #495, add treble check *immediately* before appending to servers collection

parent a2ee0280
......@@ -905,7 +905,11 @@ internal ServerEndPoint GetServerEndPoint(EndPoint endpoint)
if (isDisposed) throw new ObjectDisposedException(ToString());
server = new ServerEndPoint(this, endpoint, null);
servers.Add(endpoint, server);
// ^^ this could indirectly cause servers to become changes, so treble-check!
if (!servers.ContainsKey(endpoint))
{
servers.Add(endpoint, server);
}
var newSnapshot = serverSnapshot;
Array.Resize(ref newSnapshot, newSnapshot.Length + 1);
......@@ -1226,7 +1230,11 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, Text
if (server == null)
{
server = new ServerEndPoint(this, endpoint, log);
servers.Add(endpoint, server);
// ^^ this could indirectly cause servers to become changes, so treble-check!
if (!servers.ContainsKey(endpoint))
{
servers.Add(endpoint, server);
}
}
serverSnapshot[index++] = server;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment