Skip to content

Commit

Permalink
[mdns-avahi] allow UnsubscribeService/Host() to remove non-present …
Browse files Browse the repository at this point in the history
…entries

This commit adds a similar change to openthread#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.
  • Loading branch information
abtink committed Feb 29, 2024
1 parent 2279c02 commit 2964840
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mdns/mdns_avahi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServiceSubscription> service = std::move(*it);
Expand Down Expand Up @@ -1106,7 +1106,7 @@ void PublisherAvahi::UnsubscribeHost(const std::string &aHostName)
mSubscribedHosts.begin(), mSubscribedHosts.end(),
[&aHostName](const std::unique_ptr<HostSubscription> &aHost) { return aHost->mHostName == aHostName; });

assert(it != mSubscribedHosts.end());
VerifyOrExit(it != mSubscribedHosts.end());

{
std::unique_ptr<HostSubscription> host = std::move(*it);
Expand Down

0 comments on commit 2964840

Please sign in to comment.