Fix application (chip-device-ctrl) hang caused by mdns resolve callback not being called #7229
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.
Problem
What is being fixed?
chip-device-ctrl always hangs when issuing resolve command. This happens in both cases, on resolve success and failure.
Change overview
What's in this PR
DeviceCommissioner::OnNodeIdResolved and DeviceCommissioner::OnNodeIdResolutionFailed fails to forward resolve results to DeviceController routines with same name since at that point the pairing and credentials processing is already finished when the variable mDeviceBeingPaired is reset to kNumMaxActiveDevices in DeviceCommissioner::RendezvousCleanup. This causes hang of the application which waits forever for a callback that never comes and has to be force quit.
Testing
How was this tested? (at least one bullet point required)
connect -ble 3840 12345678 12344321
zcl NetworkCommissioning AddThreadNetwork 12344321 0 0 operationalDataset=hex:000300001902088836262BBA63449605102799757C265665FC001078FDE764698D01022DF2 breadcrumb=0 timeoutMs=5000
zcl NetworkCommissioning EnableNetwork 12344321 0 0 networkID=hex:8836262BBA634496 breadcrumb=0 timeoutMs=5000
close-ble
resolve 5544332211 12344321
result without the fix: application hangs and needs to be force quit
result with the fix: application does not hang, device address gets correctly updated. Sample output:
chip-device-ctrl > resolve 5544332211 12344321
[1622196594583] [0xd702a] CHIP: [DL] Mdns: OnGetAddrInfo hostname:chiplock.local.
[1622196607629] [0xd702a] CHIP: [DIS] Node ID resolved for 0x0000000000BC5C01
[1622196778078] [0xd702a] CHIP: [CTL] SyncSetKeyValue on PairedDevicebc5c01
Node address has been updated
Current address: fdd4:5b3d:373d::60db:1ad2:1bdc:846d:11097
chip-device-ctrl >
Notes
The first part DeviceCommissioner::OnNodeIdResolved is now identical to master due to subsequent #7213 being merged, but the second part DeviceCommissioner::OnNodeIdResolutionFailed is not addressed by 7213 and needs the same fix as here.
Resolved editorial conflict with master but my initial version was better, there is no point in declaring Device * device = nullptr; outside of if block.. other than that it is the same.