Skip to content

Commit 43e0668

Browse files
committed
Add ScheduleWork for HandleResolveTask
1 parent c6feed9 commit 43e0668

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/platform/Tizen/DnssdImpl.cpp

+27-1
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,37 @@ 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+
chip::DeviceLayer::StackLock lock;
290+
rCtx->Finalize(CHIP_NO_ERROR);
291+
}
292+
279293
gboolean OnResolveFinalize(gpointer userData)
280294
{
281295
ChipLogDetail(DeviceLayer, "DNSsd %s", __func__);
282296
auto rCtx = reinterpret_cast<chip::Dnssd::ResolveContext *>(userData);
297+
if (!rCtx)
298+
{
299+
ChipLogError(DeviceLayer, "Null context in OnResolveFinalize");
300+
return G_SOURCE_REMOVE;
301+
}
283302

284-
rCtx->Finalize(CHIP_NO_ERROR);
303+
CHIP_ERROR err = chip::DeviceLayer::PlatformMgr().ScheduleWork(HandleResolveTask, reinterpret_cast<intptr_t>(rCtx));
304+
if (err != CHIP_NO_ERROR)
305+
{
306+
ChipLogError(DeviceLayer, "Failed to schedule resolve task: %s", err.AsString());
307+
rCtx->mInstance->RemoveContext(rCtx);
308+
return G_SOURCE_REMOVE;
309+
}
285310

286311
rCtx->mInstance->RemoveContext(rCtx);
287312
return G_SOURCE_REMOVE;
@@ -290,6 +315,7 @@ gboolean OnResolveFinalize(gpointer userData)
290315
void OnResolve(dnssd_error_e result, dnssd_service_h service, void * userData)
291316
{
292317
ChipLogDetail(DeviceLayer, "DNSsd %s", __func__);
318+
293319
auto rCtx = reinterpret_cast<chip::Dnssd::ResolveContext *>(userData);
294320

295321
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)