@@ -371,6 +371,7 @@ void BrowseContext::DispatchPartialSuccess()
371
371
callback (context, services.data (), services.size (), false , CHIP_NO_ERROR);
372
372
sContextDispatchingSuccess = nullptr ;
373
373
services.clear ();
374
+ domainNames.clear ();
374
375
}
375
376
376
377
void BrowseContext::OnBrowse (DNSServiceFlags flags, const char * name, const char * type, const char * domain, uint32_t interfaceId)
@@ -391,6 +392,7 @@ void BrowseContext::OnBrowseAdd(const char * name, const char * type, const char
391
392
VerifyOrReturn (IsLocalDomain (domain));
392
393
auto service = GetService (name, type, protocol, interfaceId);
393
394
services.push_back (service);
395
+ domainNames.push_back (std::make_pair (service, std::string (domain)));
394
396
}
395
397
396
398
void BrowseContext::OnBrowseRemove (const char * name, const char * type, const char * domain, uint32_t interfaceId)
@@ -401,6 +403,13 @@ void BrowseContext::OnBrowseRemove(const char * name, const char * type, const c
401
403
VerifyOrReturn (name != nullptr );
402
404
VerifyOrReturn (IsLocalDomain (domain));
403
405
406
+ domainNames.erase (std::remove_if (domainNames.begin (), domainNames.end (),
407
+ [name, type, interfaceId](const auto & domainName) {
408
+ return strcmp (domainName.first .mName , name) == 0 && domainName.first .mType == type &&
409
+ domainName.first .mInterface == chip::Inet::InterfaceId (interfaceId);
410
+ }),
411
+ domainNames.end ());
412
+
404
413
services.erase (std::remove_if (services.begin (), services.end (),
405
414
[name, type, interfaceId](const DnssdService & service) {
406
415
return strcmp (name, service.mName ) == 0 && type == GetFullType (&service) &&
0 commit comments