espressif / esp-protocols

Collection of ESP-IDF components related to networking protocols
181 stars 126 forks source link

fix(mdns): remove same protocol services with different instances #574

Closed DejinChen closed 4 months ago

DejinChen commented 4 months ago

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:

  1. Modify remove services action to remove the same instance name services.
  2. Verify that the service already has the same subtype before adding.