-
Notifications
You must be signed in to change notification settings - Fork 240
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
[mdns] unify the behavior of Stop()
between avahi and mDNSResponder
#2725
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2725 +/- ##
===========================================
- Coverage 55.77% 43.60% -12.17%
===========================================
Files 87 108 +21
Lines 6890 13355 +6465
Branches 0 953 +953
===========================================
+ Hits 3843 5824 +1981
- Misses 3047 7223 +4176
- Partials 0 308 +308 ☔ View full report in Codecov by Sentry. |
@@ -241,6 +241,8 @@ void PublisherMDnsSd::Stop(StopMode aStopMode) | |||
{ |
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.
A general question about how the Stop()
method is intended to be used:
Stop()
can be called when the underlying mDNS provider (e.g., mDNSResponder) is itself stopped.- It may be called when the underlying mDNS provider is still active and running, but for some other reason, we are stopping all mDNS operations.
I noticed we have StopMode
input with Stop(kNormalStop)
or kStopOnServiceNotRunningError
, which makes it seem that both cases are used and should be supported.
If we need to support both cases (which I think we need to), then I think we should handle them differently.
- In the first case, it is okay/desired to set
mState
early to ensure theClear()
methods (destructors andUnregister()
calls) won't call mDNSResponder APIs anymore, as it is no longer running. - In the second case, we do want to call mDNSResponder APIs to clear any previously registered entries (otherwise, it continues to publish the service/host info). But then setting
mState
early in the method will cause these to be skipped (which would be incorrect).
My suggestion is that we track whether the mDNSResponder is active in a separate variable other than mState
, which we then check (along with mState
) to decide if we can call any of the mDNSResponder (or Avahi) APIs. Thoughts?
In the
Stop()
method, thePublisher
will: