Skip to content

Commit

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

This commit 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 authored Feb 29, 2024
1 parent 98dda6c commit 2279c02
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mdns/mdns_mdnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ void PublisherMDnsSd::UnsubscribeService(const std::string &aType, const std::st
[&aType, &aInstanceName](const std::unique_ptr<ServiceSubscription> &aService) {
return aService->mType == aType && aService->mInstanceName == aInstanceName;
});
assert(it != mSubscribedServices.end());
VerifyOrExit(it != mSubscribedServices.end());

mSubscribedServices.erase(it);

Expand Down Expand Up @@ -998,7 +998,7 @@ void PublisherMDnsSd::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());

mSubscribedHosts.erase(it);

Expand Down

0 comments on commit 2279c02

Please sign in to comment.