mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix(cluster): Fix race when setting cluster config (#1428)
* fix(cluster): Fix race when setting cluster config * Return `shared_ptr` from Create factory function.
This commit is contained in:
parent
ba641677ac
commit
14e9ba4849
3 changed files with 6 additions and 14 deletions
|
@ -103,13 +103,13 @@ bool IsConfigValid(const ClusterConfig::ClusterShards& new_config) {
|
|||
} // namespace
|
||||
|
||||
/* static */
|
||||
unique_ptr<ClusterConfig> ClusterConfig::CreateFromConfig(string_view my_id,
|
||||
shared_ptr<ClusterConfig> ClusterConfig::CreateFromConfig(string_view my_id,
|
||||
const ClusterShards& config) {
|
||||
if (!IsConfigValid(config)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
unique_ptr<ClusterConfig> result(new ClusterConfig());
|
||||
shared_ptr<ClusterConfig> result(new ClusterConfig());
|
||||
|
||||
result->config_ = config;
|
||||
|
||||
|
@ -254,7 +254,7 @@ optional<ClusterConfig::ClusterShards> BuildClusterConfigFromJson(const JsonType
|
|||
} // namespace
|
||||
|
||||
/* static */
|
||||
unique_ptr<ClusterConfig> ClusterConfig::CreateFromConfig(string_view my_id,
|
||||
shared_ptr<ClusterConfig> ClusterConfig::CreateFromConfig(string_view my_id,
|
||||
const JsonType& json_config) {
|
||||
optional<ClusterShards> config = BuildClusterConfigFromJson(json_config);
|
||||
if (!config.has_value()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue