Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nivi-apple committed Apr 11, 2024
1 parent 4b9e59b commit ab7d2eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/platform/Darwin/DnssdContexts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,7 @@ ResolveContext::ResolveContext(DiscoverNodeDelegate * delegate, chip::Inet::IPAd

ResolveContext::~ResolveContext()
{
if (isSRPTimerRunning)
{
CancelSRPTimer();
}
CancelSRPTimerIfRunning();
}

void ResolveContext::DispatchFailure(const char * errorStr, CHIP_ERROR err)
Expand Down Expand Up @@ -647,10 +644,14 @@ void ResolveContext::SRPTimerExpiredCallback(chip::System::Layer * systemLayer,
sdCtx->Finalize();
}

void ResolveContext::CancelSRPTimer()
void ResolveContext::CancelSRPTimerIfRunning()
{
DeviceLayer::SystemLayer().CancelTimer(SRPTimerExpiredCallback, static_cast<void *>(this));
ChipLogProgress(Discovery, "SRP resolve timer for %s cancelled; resolve timed out", instanceName.c_str());
if (isSRPTimerRunning)
{
DeviceLayer::SystemLayer().CancelTimer(SRPTimerExpiredCallback, static_cast<void *>(this));
ChipLogProgress(Discovery, "SRP resolve timer for %s cancelled; resolve timed out", instanceName.c_str());
isSRPTimerRunning = false;
}
}

CHIP_ERROR ResolveContext::OnNewAddress(const InterfaceKey & interfaceKey, const struct sockaddr * address)
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Darwin/DnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ static void OnGetAddrInfo(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t i
// If we now don't need to have a timer while we wait for SRP results, ensure that there is no such
// timer running. Otherwise the timer could fire before we get the rest of the results that flags
// say are coming, and trigger a finalize before we have all the data that is already available.
if (sdCtx->isSRPTimerRunning && !sdCtx->shouldStartSRPTimerForResolve)
if (!sdCtx->shouldStartSRPTimerForResolve)
{
sdCtx->CancelSRPTimer();
sdCtx->CancelSRPTimerIfRunning();
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Darwin/DnssdImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ struct ResolveContext : public GenericContext
* @brief Cancels the timer that was started to wait for the resolution on the kSRPDot domain to happen.
*
*/
void CancelSRPTimer();
void CancelSRPTimerIfRunning();

private:
/**
Expand Down

0 comments on commit ab7d2eb

Please sign in to comment.