diff --git a/internal/platform/implementation/linux/avahi.h b/internal/platform/implementation/linux/avahi.h index 7c60c961..51002bfe 100644 --- a/internal/platform/implementation/linux/avahi.h +++ b/internal/platform/implementation/linux/avahi.h @@ -60,10 +60,11 @@ class ServiceBrowser : public sdbus::ProxyInterfaces< public: ServiceBrowser(sdbus::IConnection &system_bus, const sdbus::ObjectPath &service_browser_object_path, - api::WifiLanMedium::DiscoveredServiceCallback callback) + api::WifiLanMedium::DiscoveredServiceCallback callback, + std::shared_ptr avahi_server) : ProxyInterfaces(system_bus, "org.freedesktop.Avahi", service_browser_object_path), - discovery_cb_(std::move(callback)) { + discovery_cb_(std::move(callback)), server_(avahi_server) { registerProxy(); } ~ServiceBrowser() { diff --git a/internal/platform/implementation/linux/wifi_lan.cc b/internal/platform/implementation/linux/wifi_lan.cc index 3ebf1250..0c482816 100644 --- a/internal/platform/implementation/linux/wifi_lan.cc +++ b/internal/platform/implementation/linux/wifi_lan.cc @@ -26,7 +26,7 @@ namespace linux { WifiLanMedium::WifiLanMedium(sdbus::IConnection &system_bus) : system_bus_(system_bus), network_manager_(std::make_shared(system_bus)), - avahi_(std::make_unique(system_bus)) {} + avahi_(std::make_shared(system_bus)) {} bool WifiLanMedium::IsNetworkConnected() const { auto state = network_manager_->getState(); @@ -151,7 +151,7 @@ bool WifiLanMedium::StartDiscovery( service_browsers_.emplace( service_type, std::make_unique( - system_bus_, browser_object_path, std::move(callback))); + system_bus_, browser_object_path, std::move(callback), avahi_)); } catch (const sdbus::Error &e) { DBUS_LOG_METHOD_CALL_ERROR(avahi_, "ServiceBrowserPrepare", e); return false; diff --git a/internal/platform/implementation/linux/wifi_lan.h b/internal/platform/implementation/linux/wifi_lan.h index 856cfc7a..04a736e8 100644 --- a/internal/platform/implementation/linux/wifi_lan.h +++ b/internal/platform/implementation/linux/wifi_lan.h @@ -50,7 +50,7 @@ private: std::shared_ptr network_manager_; - std::unique_ptr avahi_; + std::shared_ptr avahi_; absl::Mutex entry_groups_mutex_; absl::flat_hash_map,