Commit ad6694a6 authored by Nick Craver's avatar Nick Craver

Fix race in ReconfigureAsync() snapshot creation

Though we lock on servers here, serverSnapshot is iterated in more cases, this reconfiguration iteration leaves null entries in the array causing downstream issues.
parent 0e08f338
......@@ -1229,7 +1229,7 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, Text
int index = 0;
lock (servers)
{
serverSnapshot = new ServerEndPoint[configuration.EndPoints.Count];
var newSnapshot = new ServerEndPoint[configuration.EndPoints.Count];
foreach (var endpoint in configuration.EndPoints)
{
var server = (ServerEndPoint)servers[endpoint];
......@@ -1242,8 +1242,9 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, Text
servers.Add(endpoint, server);
}
}
serverSnapshot[index++] = server;
newSnapshot[index++] = server;
}
serverSnapshot = newSnapshot;
}
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