ESP-Matter may publish services with the same protocol and service type but different instance names. e.g., ''a.matter._tcp" and "b.matter._tcp". When service info changed, we have to remove all "matter._tcp" service through mdns_service_remove(const char *service_type, const char *proto) and re-add new service. But now, the the different instance name services can not be removed at the same time. And re-adding will lead a memory leak problem for the unremoved services with the same subtype.
Change overview:
Modify remove services action to remove the same instance name services.
Verify that the service already has the same subtype before adding.
Problem
ESP-Matter may publish services with the same protocol and service type but different instance names. e.g., ''a.matter._tcp" and "b.matter._tcp". When service info changed, we have to remove all "matter._tcp" service through
mdns_service_remove(const char *service_type, const char *proto)
and re-add new service. But now, the the different instance name services can not be removed at the same time. And re-adding will lead a memory leak problem for the unremoved services with the same subtype.Change overview: