The way get_name() used the lock is completely wrong: in the protected
code block, it do not access anything that needs to be protected. All
it effectively does is return the `this` pointer with an offset to the
`module_name` field; but it does not actually access the field. The
actual access is done by the caller, after the mutex has been unlocked
already.
But anyway, `module_name` does not need any protection. It is `const`
and thus cannot be modified by other threads. So instead of fixing
the return value (removing the `&`), let's just remove the lock.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
}
const std::string &get_name() const {
- std::lock_guard l(lock) ; return module_name;
+ return module_name;
}
const std::string &get_error_string() const {
std::lock_guard l(lock) ; return error_string;