mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 07:43:34 +08:00
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:
@@ -183,9 +183,6 @@ Mavlink::Mavlink() :
|
|||||||
|
|
||||||
Mavlink::~Mavlink()
|
Mavlink::~Mavlink()
|
||||||
{
|
{
|
||||||
perf_free(_loop_perf);
|
|
||||||
perf_free(_loop_interval_perf);
|
|
||||||
|
|
||||||
if (_task_running) {
|
if (_task_running) {
|
||||||
/* task wakes up every 10ms or so at the longest */
|
/* task wakes up every 10ms or so at the longest */
|
||||||
_task_should_exit = true;
|
_task_should_exit = true;
|
||||||
@@ -205,6 +202,9 @@ Mavlink::~Mavlink()
|
|||||||
}
|
}
|
||||||
} while (_task_running);
|
} while (_task_running);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
perf_free(_loop_perf);
|
||||||
|
perf_free(_loop_interval_perf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2458,9 +2458,6 @@ Mavlink::task_main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
perf_end(_loop_perf);
|
perf_end(_loop_perf);
|
||||||
|
|
||||||
/* confirm task running only once fully initialized */
|
|
||||||
_task_running = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* first wait for threads to complete before tearing down anything */
|
/* first wait for threads to complete before tearing down anything */
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ private:
|
|||||||
|
|
||||||
uORB::PublicationQueued<telemetry_status_s> _telem_status_pub{ORB_ID(telemetry_status)};
|
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 bool _boot_complete;
|
||||||
static constexpr int MAVLINK_MAX_INSTANCES{4};
|
static constexpr int MAVLINK_MAX_INSTANCES{4};
|
||||||
static constexpr int MAVLINK_MIN_INTERVAL{1500};
|
static constexpr int MAVLINK_MIN_INTERVAL{1500};
|
||||||
|
|||||||
Reference in New Issue
Block a user