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:
Beat Küng 2016-10-31 11:45:37 +01:00 committed by Lorenz Meier
parent 2908f1c16d
commit 00cd2902c7

View File

@ -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;