From b165f1e88ba6370e0a8cab052d889d51cb39a2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Grzebieluch?= Date: Mon, 10 Jul 2023 10:32:18 +0200 Subject: [PATCH] utils: error injection: check if it is an ongoing one-shot injection in is_enabled Change it for consistency with `enabled_injections`. Closes #14597 --- utils/error_injection.hh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/utils/error_injection.hh b/utils/error_injection.hh index 6beade0ed4..eb8bd194e1 100644 --- a/utils/error_injection.hh +++ b/utils/error_injection.hh @@ -224,7 +224,8 @@ private: std::map _enabled; bool is_enabled(const std::string_view& injection_name) const { - return _enabled.contains(injection_name); + auto data = get_data(injection_name); + return data && !data->is_ongoing_oneshot(); } bool is_one_shot(const std::string_view& injection_name) const { @@ -235,6 +236,14 @@ private: return it->second.one_shot; } + injection_data const* get_data(const std::string_view& injection_name) const { + const auto it = _enabled.find(injection_name); + if (it == _enabled.end()) { + return nullptr; + } + return &it->second; + } + injection_data* get_data(const std::string_view& injection_name) { const auto it = _enabled.find(injection_name); if (it == _enabled.end()) {