[DNSSD] Prevent failure when Dnssd::ServiceAdvertiser is not initialized#42994
[DNSSD] Prevent failure when Dnssd::ServiceAdvertiser is not initialized#42994jepenven-silabs wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses spurious error logging that occurs when DNSSD::StartServer is called on non-commissioned devices. The root cause is that ServiceAdvertiser::Instance().Init() transitions to an Initializing state rather than Initialized, causing subsequent operations to fail their state checks. The fix adds conditional checks using IsInitialized() before calling operations that require full initialization.
Changes:
- Added
IsInitialized()guards aroundRemoveServices(),AdvertiseCommissionableNode(), andFinalizeServiceUpdate()calls - Changed log level from
ChipLogProgresstoChipLogDetailfor commission parameter advertising
6584829 to
66efbd0
Compare
There was a problem hiding this comment.
Code Review
This pull request aims to prevent error logs when Dnssd::ServiceAdvertiser is not yet initialized by adding checks before calling its methods. While this is a good step, the current implementation is incomplete, as several other calls that depend on the advertiser are still made without these checks. I've provided a suggestion for a more comprehensive and cleaner fix that wraps all dependent calls in a single initialization check, aligning with the principle of ensuring robust initialization and preventing unstable states. This will ensure all potential errors are caught and improves the code's readability and robustness.
|
PR #42994: Size comparison from 6d8d7f7 to 66efbd0 Full report (35 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
|
66efbd0 to
d040112
Compare
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #42994 +/- ##
==========================================
- Coverage 55.57% 55.57% -0.01%
==========================================
Files 1630 1630
Lines 111223 111228 +5
Branches 13409 13411 +2
==========================================
+ Hits 61812 61814 +2
- Misses 49411 49414 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
|
PR #42994: Size comparison from 9cf1485 to 0378c0b Full report (21 builds for bl602, bl616, bl702, bl702l, cc13x4_26x4, cc32xx, nrfconnect, psoc6, qpg, realtek, stm32)
|
Summary
Upon booting a non-commissionned device
DNSSD::StartServeris called twice triggering 6 logs of errors.These errors comes from the fact that calling the
Dnssd::ServiceAdvertiser::Instance().Init()functions does not put the ServiceAdvertiser in theInitializedstate but in theInitializingstate cause subsequent function to fail automatically when they check if the state isInitialized. This PR prevent this failure by doing the check before calling said functions.Related issues
Relates to #13844 as this is is more of a workaround to alleviate the symptoms of a confusing Init sequence for the DNSSD.
Testing
Tested with a Silicon Labs EFR32MG24 light-switch app. Errors logs do not show up with this fix and the device is able to advertise and commission as expected.
Upon Power-cycle, the device is still able to advertise as expected