Skip to content

Commit

Permalink
Update src/platform/tests/TestDnssd.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Apr 26, 2023
1 parent c60cab3 commit f5dbb09
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/platform/tests/TestDnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ static void HandleResolve(void * context, DnssdService * result, const chip::Spa
if (ctx->mBrowsedServicesCount == ++ctx->mResolvedServicesCount)
{
chip::DeviceLayer::SystemLayer().CancelTimer(Timeout, context);
// StopEventLoopTask can be called from any thread, but when called from
// non-Matter one it will lock the Matter stack. The same locking rules
// are required when the resolve callback (this one) is called. In order
// to avoid deadlocks, we need to call the StopEventLoopTask from inside
// the Matter event loop by scheduling a lambda.
chip::DeviceLayer::SystemLayer().ScheduleLambda([]() {
// After last service is resolved, stop the event loop,
// so the test case can gracefully exit.
Expand Down

0 comments on commit f5dbb09

Please sign in to comment.