Make Darwin HostNameRegistrar safer to use. #25983
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are two main changes here:
When we shut down the Matter stack, we should remove all our advertisements adn stop monitoring for network interface changes. That's what the change to ChipDnssdShutdown does.
It's theoretically possible for the block HostNameRegistrar passes to nw_path_monitor_set_update_handler to run after the HostNameRegistrar is destroyed. Guard against that with a shared_ptr that keeps track of the liveness state of the HostNameRegistrar.
The changes to the member initialization of HostNameRegistrar are just for safety's sake, in case its destructor ever gets called without Init() having been called first. Right now that is not possible, but better to not rely on that.