Commit b42583a8 authored by Marc Gravell's avatar Marc Gravell

Avoid race condition when adding servers

parent 3fca0020
...@@ -1222,10 +1222,14 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, Text ...@@ -1222,10 +1222,14 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, Text
serverSnapshot = new ServerEndPoint[configuration.EndPoints.Count]; serverSnapshot = new ServerEndPoint[configuration.EndPoints.Count];
foreach (var endpoint in configuration.EndPoints) foreach (var endpoint in configuration.EndPoints)
{ {
var server = new ServerEndPoint(this, endpoint, log); var server = (ServerEndPoint)servers[endpoint];
serverSnapshot[index++] = server; if (server == null)
{
server = new ServerEndPoint(this, endpoint, log);
servers.Add(endpoint, server); servers.Add(endpoint, server);
} }
serverSnapshot[index++] = server;
}
} }
foreach (var server in serverSnapshot) foreach (var server in serverSnapshot)
{ {
......
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