Skip to content

Commit

Permalink
telemetry: fix scope of subscription lock
Browse files Browse the repository at this point in the history
It looks like the lock was released too early, so before the
_rc_status_subscription and _health_all_ok_subscription were used.

This presumably lead to a address sanitizer failure in CI.
  • Loading branch information
julianoes committed May 23, 2022
1 parent 01e1d55 commit 14918d7
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/mavsdk/plugins/telemetry/telemetry_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,16 +1130,14 @@ void TelemetryImpl::process_sys_status(const mavlink_message_t& message)
// If the flag is not supported yet, we fall back to the param.
}

{
std::lock_guard<std::mutex> lock(_subscription_mutex);
if (_rc_status_subscription) {
auto callback = _rc_status_subscription;
auto arg = rc_status();
_parent->call_user_callback([callback, arg]() { callback(arg); });
}
std::lock_guard<std::mutex> lock(_subscription_mutex);
if (_rc_status_subscription) {
auto callback = _rc_status_subscription;
auto arg = rc_status();
_parent->call_user_callback([callback, arg]() { callback(arg); });
}
const bool armable = sys_status.onboard_control_sensors_health & MAV_SYS_STATUS_PREARM_CHECK;

const bool armable = sys_status.onboard_control_sensors_health & MAV_SYS_STATUS_PREARM_CHECK;
set_health_armable(armable);
if (_health_all_ok_subscription) {
auto callback = _health_all_ok_subscription;
Expand Down

0 comments on commit 14918d7

Please sign in to comment.