Skip to content

Commit

Permalink
[mdns-msdnssd] simplify service and host registrations
Browse files Browse the repository at this point in the history
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
abtink committed Sep 10, 2023
1 parent 8a280e3 commit dbcf7cd
Show file tree
Hide file tree
Showing 2 changed files with 247 additions and 286 deletions.
Loading

0 comments on commit dbcf7cd

Please sign in to comment.