mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 01:23:34 +08:00
fix logger: avoid leaking file descriptor in get_log_time()
orb_subscribe can succeed, but if there is no publisher, orb_copy will fail. We still need to unsubscribe in that case.
This commit is contained in:
@@ -1124,13 +1124,14 @@ bool Logger::get_log_time(struct tm *tt, bool boot_time)
|
|||||||
|
|
||||||
if (orb_copy(ORB_ID(vehicle_gps_position), vehicle_gps_position_sub, &gps_pos) == 0) {
|
if (orb_copy(ORB_ID(vehicle_gps_position), vehicle_gps_position_sub, &gps_pos) == 0) {
|
||||||
utc_time_sec = gps_pos.time_utc_usec / 1e6;
|
utc_time_sec = gps_pos.time_utc_usec / 1e6;
|
||||||
orb_unsubscribe(vehicle_gps_position_sub);
|
|
||||||
|
|
||||||
if (gps_pos.fix_type >= 2 && utc_time_sec >= GPS_EPOCH_SECS) {
|
if (gps_pos.fix_type >= 2 && utc_time_sec >= GPS_EPOCH_SECS) {
|
||||||
use_clock_time = false;
|
use_clock_time = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
orb_unsubscribe(vehicle_gps_position_sub);
|
||||||
|
|
||||||
if (use_clock_time) {
|
if (use_clock_time) {
|
||||||
/* take clock time if there's no fix (yet) */
|
/* take clock time if there's no fix (yet) */
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|||||||
Reference in New Issue
Block a user