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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dnssd-plat] integrate DnssdPlatform into Application #2677
base: main
Are you sure you want to change the base?
[dnssd-plat] integrate DnssdPlatform into Application #2677
Changes from all commits
b4d5157
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed
SIGPIPE
signal was triggred and it made the program exit when calling mDNSResponder API. Not sure if ignoring the signal is fine.@abtink
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to understand why/how this is being signaled. Ignoring it may cause more harm later on, especially if it is happening due to some module not being ready or set up.
It seems to originate from us calling the mDNSResponder APIs?
My guess is that maybe we call an API somehow when the underlying mDNSResponder is not yet ready (too early)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It got SIGPIPE at this line:
ot-br-posix/src/mdns/mdns_mdnssd.cpp
Line 748 in 3f28d4c
DNSServiceRemoveRecord
. At that time the underlying mDNSResponder wasn't ready.IIUC mDNSResponder supports turning the SIGPIPE off on OSX: https://github.com/apple-oss-distributions/mDNSResponder/blob/71e6611203d57c78b26fd505d98cb57a33d00880/mDNSShared/dnssd_clientstub.c#L839. So I think it should be fine for us to ignore it? Though the scope is different (per process vs per socket).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think it would be better to investigate and understand this better.
We have
State
inPublisher
to track when the underlying mDNS is ready or not, and there are explicit checks before all method calls, like this:So why do we get to this part of the code where it may not be ready? Do we not detect that
State
has changed and it is not ready? Or are there some other missing state checks somewhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scenario is
mdnsd
gets restarted.Publisher
noticed this viakDNSServiceErr_ServiceNotRunning
error code, then it tries to restart:ot-br-posix/src/mdns/mdns_mdnssd.cpp
Line 391 in e2f3c1f
Stop()
, it wants to remove all registrations.ot-br-posix/src/mdns/mdns_mdnssd.cpp
Line 260 in e2f3c1f
DNSServiceRemoveRecord
.ot-br-posix/src/mdns/mdns_mdnssd.cpp
Line 748 in e2f3c1f
Per your idea I think we should add/move such checks into every registration type's
Register
orUnregister
method. I can send a PR later.However, I think this cannot fully solve the issue. The restart of
mdnsd
could happen at any time. When it restarts right before theDNSServiceRemoveRecord
call, it will cause the SIGPIPE beforePublisher
handles the state change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the details. I think we should also change order in
Stop()
and setmState
first before the list/entry deallocation calls.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sent #2725 to apply the suggested order of actions in
Stop()
.