uorb callbacks: fix unregister ordering to avoid race conditions

The order should be: first unregister, then remove the item from the
runnable queue.
This commit is contained in:
Beat Küng 2020-03-09 12:07:36 +01:00 committed by Daniel Agar
parent 18bc6cf872
commit 3fef401e81
4 changed files with 7 additions and 7 deletions

View File

@ -126,8 +126,8 @@ bool MixingOutput::updateSubscriptions(bool allow_wq_switch)
if (_scheduling_policy == SchedulingPolicy::Auto) {
// first clear everything
_interface.ScheduleClear();
unregister();
_interface.ScheduleClear();
// if subscribed to control group 0 or 1 then move to the rate_ctrl WQ
const bool sub_group_0 = (_groups_required & (1 << 0));

View File

@ -71,14 +71,14 @@ bool VehicleAcceleration::Start()
void VehicleAcceleration::Stop()
{
Deinit();
// clear all registered callbacks
for (auto &sub : _sensor_sub) {
sub.unregisterCallback();
}
_sensor_selection_sub.unregisterCallback();
Deinit();
}
void VehicleAcceleration::CheckFilters()

View File

@ -74,14 +74,14 @@ bool VehicleAngularVelocity::Start()
void VehicleAngularVelocity::Stop()
{
Deinit();
// clear all registered callbacks
for (auto &sub : _sensor_sub) {
sub.unregisterCallback();
}
_sensor_selection_sub.unregisterCallback();
Deinit();
}
void VehicleAngularVelocity::CheckFilters()

View File

@ -66,11 +66,11 @@ bool VehicleIMU::Start()
void VehicleIMU::Stop()
{
Deinit();
// clear all registered callbacks
_sensor_accel_integrated_sub.unregisterCallback();
_sensor_gyro_integrated_sub.unregisterCallback();
Deinit();
}
void VehicleIMU::ParametersUpdate(bool force)