From 00cd2902c785fd7d2d0571c5040e97efaa421d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 31 Oct 2016 11:45:37 +0100 Subject: [PATCH] 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. --- src/modules/logger/logger.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/logger/logger.cpp b/src/modules/logger/logger.cpp index b787e7a6ae..abc042c681 100644 --- a/src/modules/logger/logger.cpp +++ b/src/modules/logger/logger.cpp @@ -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;