diff --git a/lib/everest/framework/include/utils/error/error_manager_impl.hpp b/lib/everest/framework/include/utils/error/error_manager_impl.hpp index 870888d590..27af5ba076 100644 --- a/lib/everest/framework/include/utils/error/error_manager_impl.hpp +++ b/lib/everest/framework/include/utils/error/error_manager_impl.hpp @@ -6,6 +6,7 @@ #include #include +#include #include @@ -68,6 +69,8 @@ class ErrorManagerImpl { std::shared_ptr database; std::list allowed_error_types; + std::mutex mutex; + PublishErrorFunc publish_raised_error; PublishErrorFunc publish_cleared_error; diff --git a/lib/everest/framework/lib/error/error_manager_impl.cpp b/lib/everest/framework/lib/error/error_manager_impl.cpp index 221a6591e8..aea9b518cf 100644 --- a/lib/everest/framework/lib/error/error_manager_impl.cpp +++ b/lib/everest/framework/lib/error/error_manager_impl.cpp @@ -49,6 +49,7 @@ void ErrorManagerImpl::raise_error(const Error& error) { return; } } + const std::lock_guard lock(mutex); if (!can_be_raised(error.type, error.sub_type)) { std::stringstream ss; ss << "Error can't be raised, because type " << error.type << ", sub_type " << error.sub_type @@ -69,6 +70,7 @@ std::list ErrorManagerImpl::clear_error(const ErrorType& type) { } std::list ErrorManagerImpl::clear_error(const ErrorType& type, const ErrorSubType& sub_type) { + const std::lock_guard lock(mutex); if (!can_be_cleared(type, sub_type)) { EVLOG_debug << "Error can't be cleared, because type " << type << ", sub_type " << sub_type << " is not active."; @@ -93,6 +95,7 @@ std::list ErrorManagerImpl::clear_error(const ErrorType& type, const E } std::list ErrorManagerImpl::clear_all_errors() { + const std::lock_guard lock(mutex); const std::list filters = {}; std::list res = database->remove_errors(filters); if (res.empty()) { @@ -111,6 +114,7 @@ std::list ErrorManagerImpl::clear_all_errors() { } std::list ErrorManagerImpl::clear_all_errors(const ErrorType& error_type) { + const std::lock_guard lock(mutex); if (!can_be_cleared(error_type)) { EVLOG_debug << "Errors can't be cleared, because type " << error_type << " is not active."; return {};