From 3fc41d70c34cc511083f630aabfaeaa968da44d5 Mon Sep 17 00:00:00 2001 From: Vibhav Pant Date: Tue, 29 Aug 2023 15:09:14 +0530 Subject: [PATCH] Free resources on destruction. --- .../platform/implementation/linux/avahi.h | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/internal/platform/implementation/linux/avahi.h b/internal/platform/implementation/linux/avahi.h index a0ed8cec..eff5f233 100644 --- a/internal/platform/implementation/linux/avahi.h +++ b/internal/platform/implementation/linux/avahi.h @@ -8,6 +8,7 @@ #include "internal/platform/implementation/linux/avahi_entrygroup_client_glue.h" #include "internal/platform/implementation/linux/avahi_server_client_glue.h" #include "internal/platform/implementation/linux/avahi_servicebrowser_client_glue.h" +#include "internal/platform/implementation/linux/dbus.h" #include "internal/platform/implementation/wifi_lan.h" namespace nearby { @@ -36,7 +37,15 @@ public: entry_group_object_path) { registerProxy(); } - ~EntryGroup() { unregisterProxy(); } + ~EntryGroup() { + try { + Free(); + } catch (const sdbus::Error &e) { + DBUS_LOG_METHOD_CALL_ERROR(this, "Free", e); + } + + unregisterProxy(); + } protected: void onStateChanged(const int32_t &state, const std::string &error) override { @@ -54,7 +63,14 @@ public: discovery_cb_(std::move(callback)) { registerProxy(); } - ~ServiceBrowser() { unregisterProxy(); } + ~ServiceBrowser() { + unregisterProxy(); + try { + Free(); + } catch (const sdbus::Error &e) { + DBUS_LOG_METHOD_CALL_ERROR(this, "Free", e); + } + } protected: void onItemNew(const int32_t &interface, const int32_t &protocol,