From a644ed90dd60b6befe88de6c852af2bf9d93e35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 31 Jan 2018 14:46:39 +0100 Subject: [PATCH] mavlink: use orb_unsubscribe() instead of close() for orb subscription --- src/modules/mavlink/mavlink_main.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index e8120da53c..fded261c9c 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -739,7 +739,7 @@ int Mavlink::mavlink_open_uart(int baud, const char *uart_name) /* if this is a config link, stay here and wait for it to open */ if (_uart_fd < 0 && _mode == MAVLINK_MODE_CONFIG) { - int armed_fd = orb_subscribe(ORB_ID(actuator_armed)); + int armed_sub = orb_subscribe(ORB_ID(actuator_armed)); struct actuator_armed_s armed; /* get the system arming state and abort on arming */ @@ -747,26 +747,27 @@ int Mavlink::mavlink_open_uart(int baud, const char *uart_name) /* abort if an arming topic is published and system is armed */ bool updated = false; - orb_check(armed_fd, &updated); + orb_check(armed_sub, &updated); if (updated) { /* the system is now providing arming status feedback. * instead of timing out, we resort to abort bringing * up the terminal. */ - orb_copy(ORB_ID(actuator_armed), armed_fd, &armed); + orb_copy(ORB_ID(actuator_armed), armed_sub, &armed); if (armed.armed) { /* this is not an error, but we are done */ + orb_unsubscribe(armed_sub); return -1; } } usleep(100000); _uart_fd = ::open(uart_name, O_RDWR | O_NOCTTY); - }; + } - ::close(armed_fd); + orb_unsubscribe(armed_sub); } if (_uart_fd < 0) {