Skip to content

Commit

Permalink
Report success and fail rate if minmdns has any broadcast failures (#…
Browse files Browse the repository at this point in the history
…17329)

* Report success and fail rate if minmdns has any broadcast failures

* Split message between success and failure for mdns
  • Loading branch information
andy31415 authored Apr 19, 2022
1 parent e4e3aea commit baf0b7b
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/lib/dnssd/minimal_mdns/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ CHIP_ERROR ServerBase::BroadcastImpl(chip::System::PacketBufferHandle && data, u
// - if at least one broadcast succeeds, assume success overall
// + some internal consistency validations for state error.

bool hadSuccesfulSend = false;
CHIP_ERROR lastError = CHIP_ERROR_NO_ENDPOINT;
unsigned successes = 0;
unsigned failures = 0;
CHIP_ERROR lastError = CHIP_ERROR_NO_ENDPOINT;

if (chip::Loop::Break == mEndpoints.ForEachActiveObject([&](auto * info) {
chip::Inet::UDPEndPoint * udp = delegate->Accept(info);
Expand Down Expand Up @@ -382,10 +383,11 @@ CHIP_ERROR ServerBase::BroadcastImpl(chip::System::PacketBufferHandle && data, u

if (err == CHIP_NO_ERROR)
{
hadSuccesfulSend = true;
successes++;
}
else
{
failures++;
lastError = err;
#if CHIP_DETAIL_LOGGING
char ifaceName[chip::Inet::InterfaceId::kMaxIfNameLength];
Expand All @@ -401,7 +403,21 @@ CHIP_ERROR ServerBase::BroadcastImpl(chip::System::PacketBufferHandle && data, u
return lastError;
}

if (!hadSuccesfulSend)
if (failures != 0)
{
// if we had failures, log if the final status was success or failure, to make log reading
// easier. Some mDNS failures may be expected (e.g. for interfaces unavailable)
if (successes != 0)
{
ChipLogDetail(Discovery, "mDNS broadcast had only partial success: %u successes and %u failures.", successes, failures);
}
else
{
ChipLogProgress(Discovery, "mDNS broadcast full failed in %u separate send attempts.", failures);
}
}

if (!successes)
{
return lastError;
}
Expand Down

0 comments on commit baf0b7b

Please sign in to comment.