mavlink: prevent race if shut down immediately

If we do mavlink stop-all right after mavlink start, we do a perf_free
before actually having stopped the threads accessing the perf counters.
This commit is contained in:
Julian Oes 2019-09-03 16:34:29 +02:00 committed by Daniel Agar
parent 0486d69240
commit b0035e5704
2 changed files with 4 additions and 7 deletions

View File

@ -183,9 +183,6 @@ Mavlink::Mavlink() :
Mavlink::~Mavlink()
{
perf_free(_loop_perf);
perf_free(_loop_interval_perf);
if (_task_running) {
/* task wakes up every 10ms or so at the longest */
_task_should_exit = true;
@ -205,6 +202,9 @@ Mavlink::~Mavlink()
}
} while (_task_running);
}
perf_free(_loop_perf);
perf_free(_loop_interval_perf);
}
void
@ -2458,9 +2458,6 @@ Mavlink::task_main(int argc, char *argv[])
}
perf_end(_loop_perf);
/* confirm task running only once fully initialized */
_task_running = true;
}
/* first wait for threads to complete before tearing down anything */

View File

@ -546,7 +546,7 @@ private:
uORB::PublicationQueued<telemetry_status_s> _telem_status_pub{ORB_ID(telemetry_status)};
bool _task_running{false};
bool _task_running{true};
static bool _boot_complete;
static constexpr int MAVLINK_MAX_INSTANCES{4};
static constexpr int MAVLINK_MIN_INTERVAL{1500};