Skip to content

Commit

Permalink
mission_raw: fix upload race condition
Browse files Browse the repository at this point in the history
This fixes the case where a rally points upload right after a geofence
upload fails with busy. That's because the work item still exists and
hasn't been cleaned up yet.

However, we can ignore that case if the work item has been done.
  • Loading branch information
julianoes committed May 23, 2024
1 parent ddb9f3b commit 3cb287f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/mavsdk/plugins/mission_raw/mission_raw_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ void MissionRawImpl::upload_mission_items_async(
uint8_t type,
const MissionRaw::ResultCallback& callback)
{
if (_last_upload.lock()) {
auto work_item = _last_upload.lock();
if (work_item && !work_item->is_done()) {
_system_impl->call_user_callback([callback]() {
if (callback) {
callback(MissionRaw::Result::Busy);
Expand Down Expand Up @@ -227,7 +228,8 @@ MissionRawImpl::download_mission()

void MissionRawImpl::download_mission_async(const MissionRaw::DownloadMissionCallback& callback)
{
if (_last_download.lock()) {
auto work_item = _last_download.lock();
if (work_item && !work_item->is_done()) {
_system_impl->call_user_callback([callback]() {
if (callback) {
std::vector<MissionRaw::MissionItem> empty_items;
Expand Down

0 comments on commit 3cb287f

Please sign in to comment.