From 2964840c5534f9738a438a55004d1061714da9fa Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 29 Feb 2024 10:58:35 -0800 Subject: [PATCH] [mdns-avahi] allow `UnsubscribeService/Host()` to remove non-present entries This commit adds a similar change to #2206 but for Avahi example. It updates `UnsubscribeService/Host()` to allow them to be called with service or host name that may not be present in the list. This situation may happen if duplicate queries are received for the same names. --- src/mdns/mdns_avahi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mdns/mdns_avahi.cpp b/src/mdns/mdns_avahi.cpp index ba01519e9c9..e059f62b151 100644 --- a/src/mdns/mdns_avahi.cpp +++ b/src/mdns/mdns_avahi.cpp @@ -1047,7 +1047,7 @@ void PublisherAvahi::UnsubscribeService(const std::string &aType, const std::str return aService->mType == aType && aService->mInstanceName == aInstanceName; }); - assert(it != mSubscribedServices.end()); + VerifyOrExit(it != mSubscribedServices.end()); { std::unique_ptr service = std::move(*it); @@ -1106,7 +1106,7 @@ void PublisherAvahi::UnsubscribeHost(const std::string &aHostName) mSubscribedHosts.begin(), mSubscribedHosts.end(), [&aHostName](const std::unique_ptr &aHost) { return aHost->mHostName == aHostName; }); - assert(it != mSubscribedHosts.end()); + VerifyOrExit(it != mSubscribedHosts.end()); { std::unique_ptr host = std::move(*it);