mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +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:
parent
2908f1c16d
commit
00cd2902c7
@ -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) {
|
||||
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) {
|
||||
use_clock_time = false;
|
||||
}
|
||||
}
|
||||
|
||||
orb_unsubscribe(vehicle_gps_position_sub);
|
||||
|
||||
if (use_clock_time) {
|
||||
/* take clock time if there's no fix (yet) */
|
||||
struct timespec ts;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user