Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mdns-msdnssd] simplify service and host registrations
This commit updates and enhances `Mdns::PublisherMDnsSd` class which implements `Publisher` using MDNSResponder as its underlying DNS-SD provider. The following changes are made: - The `PublishServiceImpl()` is updated to allocate a `DnssdServiceRegistration` and add it to the list of registrations first and then ask the it to register itself. - This simplifies the code path for invoking `ResultCallback` on success or failure (one path to handle all cases) and also makes it clear that the related `DNSServiceRef` is owned and managed by the `DnssdServiceRegistration` instance. - The `HandleRegisterResult` callback passed to MDNSResponder `DNSServiceRegister()` is defined and handled by `DnssdServiceRegistration` class instead of by the `PublisherMDnsSd`. - This simplifies the code as we no longer need to iterate through the full list of `Registration`s to find the one corresponding to a related `mServiceRef`. It also fits well with notion of `mServiceRef` being owned by a corresponding `DnssdServiceRegistration` (the destructor will `DNSServiceRefDeallocate()` the `mServiceRef` which will stop the MDNSResponder to invoke the callback). This commit also makes similar changes to `PublishHostImpl()` and `DnssdHostRegistration` but there are some additional changes specific to host registration: - The `DnssdHostRegistration` now tracks whether each host IPv6 address is registered or not. - The `DnssdHostRegistration` is also changed so that it will always remove all outstanding `DNSRecordRef` for all host IPv6 addresses. This updated and fixes the existing behavior where the records were removed only if `IsComplted()` which requires all addresses to be registered and could lead to some of address records not being removed if the host registration was replaced or deleted quickly after first registration.
- Loading branch information