Fix race condition for concurrent Updates in InMemoryConfigProvider (#1725)
This commit is contained in:
Родитель
b09b9dcf11
Коммит
407e3a7268
|
@ -107,8 +107,8 @@ namespace Yarp.ReverseProxy.Configuration
|
|||
|
||||
public void Update(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterConfig> clusters)
|
||||
{
|
||||
var oldConfig = _config;
|
||||
_config = new InMemoryConfig(routes, clusters);
|
||||
var newConfig = new InMemoryConfig(routes, clusters);
|
||||
var oldConfig = Interlocked.Exchange(ref _config, newConfig);
|
||||
oldConfig.SignalChange();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ namespace Yarp.Sample
|
|||
/// </summary>
|
||||
public void Update(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterConfig> clusters)
|
||||
{
|
||||
var oldConfig = _config;
|
||||
_config = new InMemoryConfig(routes, clusters);
|
||||
var newConfig = new InMemoryConfig(routes, clusters);
|
||||
var oldConfig = Interlocked.Exchange(ref _config, newConfig);
|
||||
oldConfig.SignalChange();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ internal class KubernetesConfigProvider : IProxyConfigProvider, IUpdateConfig
|
|||
|
||||
public Task UpdateAsync(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterConfig> clusters, CancellationToken cancellationToken)
|
||||
{
|
||||
var oldConfig = _config;
|
||||
_config = new MessageConfig(routes, clusters);
|
||||
var newConfig = new MessageConfig(routes, clusters);
|
||||
var oldConfig = Interlocked.Exchange(ref _config, newConfig);
|
||||
oldConfig.SignalChange();
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace Yarp.ReverseProxy.Configuration
|
|||
|
||||
public void Update(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterConfig> clusters)
|
||||
{
|
||||
var oldConfig = _config;
|
||||
_config = new InMemoryConfig(routes, clusters);
|
||||
var newConfig = new InMemoryConfig(routes, clusters);
|
||||
var oldConfig = Interlocked.Exchange(ref _config, newConfig);
|
||||
oldConfig.SignalChange();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ namespace Yarp.ReverseProxy.Configuration.ConfigProvider
|
|||
|
||||
public void Update(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterConfig> clusters)
|
||||
{
|
||||
var oldConfig = _config;
|
||||
_config = new InMemoryConfig(routes, clusters);
|
||||
var newConfig = new InMemoryConfig(routes, clusters);
|
||||
var oldConfig = Interlocked.Exchange(ref _config, newConfig);
|
||||
oldConfig.SignalChange();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace Yarp.ReverseProxy.Configuration
|
|||
|
||||
public void Update(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterConfig> clusters)
|
||||
{
|
||||
var oldConfig = _config;
|
||||
_config = new InMemoryConfig(routes, clusters);
|
||||
var newConfig = new InMemoryConfig(routes, clusters);
|
||||
var oldConfig = Interlocked.Exchange(ref _config, newConfig);
|
||||
oldConfig.SignalChange();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче