Skip to content

Commit

Permalink
mavlink_mission: publish mission after updating dataman
Browse files Browse the repository at this point in the history
This avoids a potential race condition when dataman also updates dataman
as a result of the publication.
  • Loading branch information
bkueng committed Nov 24, 2023
1 parent 93cae5f commit 7afa011
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/mavlink/mavlink_mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ MavlinkMissionManager::update_active_mission(dm_item_t dataman_id, uint16_t coun
_current_seq = seq;
_my_dataman_id = _dataman_id;

_offboard_mission_pub.publish(mission);

if (write_to_dataman) {
bool success = _dataman_client.writeSync(DM_KEY_MISSION_STATE, 0, reinterpret_cast<uint8_t *>(&mission),
sizeof(mission_s));
Expand All @@ -171,6 +169,8 @@ MavlinkMissionManager::update_active_mission(dm_item_t dataman_id, uint16_t coun
PX4_ERR("Can't update mission state in Dataman");
}
}

_offboard_mission_pub.publish(mission);
}

int
Expand Down

0 comments on commit 7afa011

Please sign in to comment.