Skip to content

Commit

Permalink
Add debug logs to the code that browses and resolves on SRP domain
Browse files Browse the repository at this point in the history
  • Loading branch information
nivi-apple committed Apr 5, 2024
1 parent 11da2b1 commit a0968e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/platform/Darwin/DnssdContexts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,14 @@ void ResolveContext::SRPTimerExpiredCallback(chip::System::Layer * systemLayer,
{
auto sdCtx = static_cast<ResolveContext *>(callbackContext);
VerifyOrDie(sdCtx != nullptr);
ChipLogProgress(Discovery, "SRP timer expired. Resolve completed");
sdCtx->Finalize();
}

void ResolveContext::CancelSRPTimer()
{
DeviceLayer::SystemLayer().CancelTimer(SRPTimerExpiredCallback, static_cast<void *>(this));
ChipLogProgress(Discovery, "SRP timer cancelled");
}

CHIP_ERROR ResolveContext::OnNewAddress(const InterfaceKey & interfaceKey, const struct sockaddr * address)
Expand Down
7 changes: 7 additions & 0 deletions src/platform/Darwin/DnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void LogOnFailure(const char * name, DNSServiceErrorType err)
CHIP_ERROR StartSRPTimer(uint16_t timeoutInMSecs, ResolveContext * ctx)
{
VerifyOrReturnValue(ctx != nullptr, CHIP_ERROR_INCORRECT_STATE);
ChipLogProgress(Discovery, "Starting SRP timer");
return chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds16(timeoutInMSecs),
ResolveContext::SRPTimerExpiredCallback, static_cast<void *>(ctx));
}
Expand Down Expand Up @@ -280,6 +281,7 @@ static void OnGetAddrInfo(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t i
// we are done. Otherwise start the timer to give the resolve on SRP domain some extra time to complete.
if (!sdCtx->shouldStartSRPTimerForResolve)
{
ChipLogProgress(Discovery, "SRP timer not needed for resolve. Resolve completed");
sdCtx->Finalize();
}
else
Expand Down Expand Up @@ -308,6 +310,7 @@ static void GetAddrInfo(ResolveContext * sdCtx)
{
if (interface.second.isDNSLookUpRequested)
{
ChipLogProgress(Discovery, "DNS lookup was already requested for interface id %d hostname %s isSRPResult %d. Return.", interface.first.interfaceId, interface.first.hostname, interface.first.isSRPResult);
continue;
}

Expand Down Expand Up @@ -373,11 +376,15 @@ static CHIP_ERROR Resolve(ResolveContext * sdCtx, uint32_t interfaceId, chip::In
// Otherwise we will try to resolve using both the local domain and the SRP domain.
if (domain != nullptr)
{
ChipLogProgress(Discovery, "Resolve on domain= %s type=%s name=%s interface=%", domain, PRIu32, StringOrNullMarker(type), StringOrNullMarker(name),
interfaceId);
ReturnErrorOnFailure(ResolveWithContext(sdCtx, interfaceId, type, name, domain, &sdCtx->resolveContextWithNonSRPType));
sdCtx->shouldStartSRPTimerForResolve = false;
}
else
{
ChipLogProgress(Discovery, "Resolve on domains local and SRP type=%s name=%s interface=%", domain, PRIu32, StringOrNullMarker(type), StringOrNullMarker(name),
interfaceId);
ReturnErrorOnFailure(ResolveWithContext(sdCtx, interfaceId, type, name, kLocalDot, &sdCtx->resolveContextWithNonSRPType));

ReturnErrorOnFailure(ResolveWithContext(sdCtx, interfaceId, type, name, kSRPDot, &sdCtx->resolveContextWithNonSRPType));
Expand Down

0 comments on commit a0968e8

Please sign in to comment.