@@ -276,42 +276,19 @@ void GetTextEntries(unsigned short txtLen, uint8_t * txtRecord, std::vector<chip
276
276
}
277
277
}
278
278
279
- static void HandleResolveTask ( intptr_t context )
279
+ gboolean OnResolveFinalize (gpointer userData )
280
280
{
281
281
ChipLogDetail (DeviceLayer, " DNSsd %s" , __func__);
282
- auto rCtx = reinterpret_cast <chip::Dnssd::ResolveContext *>(context);
283
- if (!rCtx)
284
- {
285
- ChipLogError (DeviceLayer, " Null context in HandleResolveTask" );
286
- return ;
287
- }
282
+ auto rCtx = reinterpret_cast <chip::Dnssd::ResolveContext *>(userData);
288
283
289
284
{
285
+ // Lock the stack mutex when calling the callback function, so that the callback
286
+ // function could safely perform message exchange (e.g. PASE session pairing).
290
287
chip::DeviceLayer::StackLock lock;
291
288
rCtx->Finalize (CHIP_NO_ERROR);
292
289
}
293
290
294
291
rCtx->mInstance ->RemoveContext (rCtx);
295
- }
296
-
297
- gboolean OnResolveFinalize (gpointer userData)
298
- {
299
- ChipLogDetail (DeviceLayer, " DNSsd %s" , __func__);
300
- auto rCtx = reinterpret_cast <chip::Dnssd::ResolveContext *>(userData);
301
- if (!rCtx)
302
- {
303
- ChipLogError (DeviceLayer, " Null context in OnResolveFinalize" );
304
- return G_SOURCE_REMOVE;
305
- }
306
-
307
- CHIP_ERROR err = chip::DeviceLayer::PlatformMgr ().ScheduleWork (HandleResolveTask, reinterpret_cast <intptr_t >(rCtx));
308
- if (err != CHIP_NO_ERROR)
309
- {
310
- ChipLogError (DeviceLayer, " Failed to schedule resolve task: %s" , err.AsString ());
311
- rCtx->mInstance ->RemoveContext (rCtx);
312
- return G_SOURCE_REMOVE;
313
- }
314
-
315
292
return G_SOURCE_REMOVE;
316
293
}
317
294
0 commit comments