Skip to content

Commit 44bd675

Browse files
committed
Add ScheduleWork for HandleResolveTask
1 parent c6feed9 commit 44bd675

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/platform/Tizen/DnssdImpl.cpp

+31-2
Original file line numberDiff line numberDiff line change
@@ -276,20 +276,49 @@ void GetTextEntries(unsigned short txtLen, uint8_t * txtRecord, std::vector<chip
276276
}
277277
}
278278

279+
static void HandleResolveTask(intptr_t context)
280+
{
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+
}
288+
289+
{
290+
chip::DeviceLayer::StackLock lock;
291+
rCtx->Finalize(CHIP_NO_ERROR);
292+
}
293+
294+
rCtx->mInstance->RemoveContext(rCtx);
295+
}
296+
279297
gboolean OnResolveFinalize(gpointer userData)
280298
{
281299
ChipLogDetail(DeviceLayer, "DNSsd %s", __func__);
282300
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+
}
283306

284-
rCtx->Finalize(CHIP_NO_ERROR);
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+
}
285314

286-
rCtx->mInstance->RemoveContext(rCtx);
287315
return G_SOURCE_REMOVE;
288316
}
289317

290318
void OnResolve(dnssd_error_e result, dnssd_service_h service, void * userData)
291319
{
292320
ChipLogDetail(DeviceLayer, "DNSsd %s", __func__);
321+
293322
auto rCtx = reinterpret_cast<chip::Dnssd::ResolveContext *>(userData);
294323

295324
chip::GAutoPtr<char> name;

src/platform/Tizen/PlatformManagerImpl.h

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener
8888
CHIP_ERROR _InitChipStack();
8989
void _Shutdown();
9090

91+
#if CHIP_STACK_LOCK_TRACKING_ENABLED
92+
bool _IsChipStackLockedByCurrentThread() const { return true; };
93+
#endif
94+
9195
// ===== Members for internal use by the following friends.
9296

9397
friend PlatformManager & PlatformMgr();

0 commit comments

Comments
 (0)