Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <list>
#include <memory>
#include <mutex>

Check warning on line 9 in lib/everest/framework/include/utils/error/error_manager_impl.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/everest/framework/include/utils/error/error_manager_impl.hpp#L9

Include file: <mutex> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <utils/error.hpp>

Expand Down Expand Up @@ -68,6 +69,8 @@
std::shared_ptr<ErrorDatabase> database;
std::list<ErrorType> allowed_error_types;

std::mutex mutex;

PublishErrorFunc publish_raised_error;
PublishErrorFunc publish_cleared_error;

Expand Down
4 changes: 4 additions & 0 deletions lib/everest/framework/lib/error/error_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void ErrorManagerImpl::raise_error(const Error& error) {
return;
}
}
const std::lock_guard<std::mutex> 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
Expand All @@ -69,6 +70,7 @@ std::list<ErrorPtr> ErrorManagerImpl::clear_error(const ErrorType& type) {
}

std::list<ErrorPtr> ErrorManagerImpl::clear_error(const ErrorType& type, const ErrorSubType& sub_type) {
const std::lock_guard<std::mutex> 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.";
Expand All @@ -93,6 +95,7 @@ std::list<ErrorPtr> ErrorManagerImpl::clear_error(const ErrorType& type, const E
}

std::list<ErrorPtr> ErrorManagerImpl::clear_all_errors() {
const std::lock_guard<std::mutex> lock(mutex);
const std::list<ErrorFilter> filters = {};
std::list<ErrorPtr> res = database->remove_errors(filters);
if (res.empty()) {
Expand All @@ -111,6 +114,7 @@ std::list<ErrorPtr> ErrorManagerImpl::clear_all_errors() {
}

std::list<ErrorPtr> ErrorManagerImpl::clear_all_errors(const ErrorType& error_type) {
const std::lock_guard<std::mutex> lock(mutex);
if (!can_be_cleared(error_type)) {
EVLOG_debug << "Errors can't be cleared, because type " << error_type << " is not active.";
return {};
Expand Down