mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-29 11:10:40 +00:00
service/qos: add constructors to service_level
Add a default constructor and a constructor which explicitly initializes all fields of the service_level structure. This is done in order to make sure that removal of the marked_for_deletion field can be done safely - otherwise, for example, service_level could be aggregate-initialized with an incomplete list of values for the fields, and removing marked_for_deletion which is in the middle of the struct would cause the is_static field to be initialized with the value that was designated for marked_for_deletion. As a bonus, make sure that marked_for_deletion and is_static bool fields are initialized in the default constructor to false in order to avoid potential undefined behavior.
This commit is contained in:
@@ -541,7 +541,7 @@ future<> service_level_controller::do_add_service_level(sstring name, service_le
|
||||
return make_ready_future();
|
||||
}
|
||||
} else {
|
||||
return do_with(service_level{.slo = slo, .is_static = is_static}, std::move(name), [this] (service_level& sl, sstring& name) {
|
||||
return do_with(service_level(slo, false, is_static), std::move(name), [this] (service_level& sl, sstring& name) {
|
||||
return container().invoke_on_all(&service_level_controller::notify_service_level_added, name, sl);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,8 +42,16 @@ namespace qos {
|
||||
*/
|
||||
struct service_level {
|
||||
service_level_options slo;
|
||||
bool marked_for_deletion;
|
||||
bool is_static;
|
||||
bool marked_for_deletion = false;
|
||||
bool is_static = false;
|
||||
|
||||
service_level() = default;
|
||||
|
||||
service_level(service_level_options slo, bool marked_for_deletion, bool is_static)
|
||||
: slo(std::move(slo))
|
||||
, marked_for_deletion(marked_for_deletion)
|
||||
, is_static(is_static)
|
||||
{}
|
||||
};
|
||||
|
||||
using update_both_cache_levels = bool_class<class update_both_cache_levels_tag>;
|
||||
|
||||
Reference in New Issue
Block a user