Skip to content

Commit

Permalink
Fix issue with StartResolver removing existing services
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian-Nordic committed Jul 30, 2021
1 parent db70d15 commit aded3bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/lib/mdns/Discovery_ImplPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ class DiscoveryImplPlatform : public ServiceAdvertiser, public Resolver
public:
CHIP_ERROR Init();

/// Starts the service advertiser if not yet started. Otherwise, removes all existing services.
CHIP_ERROR Start(Inet::InetLayer * inetLayer, uint16_t port) override;
CHIP_ERROR StartResolver(Inet::InetLayer * inetLayer, uint16_t port) override { return Start(inetLayer, port); }

/// Starts the service resolver if not yet started
CHIP_ERROR StartResolver(Inet::InetLayer * inetLayer, uint16_t port) override { return Init(); }

/// Advertises the CHIP node as an operational node
CHIP_ERROR Advertise(const OperationalAdvertisingParameters & params) override;
Expand Down
13 changes: 4 additions & 9 deletions src/lib/shell/commands/Dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace chip {
namespace Shell {

static chip::Shell::Engine sShellDnsSubcommands;
static bool isResolverStarted;

class DnsShellResolverDelegate : public chip::Mdns::ResolverDelegate
{
Expand Down Expand Up @@ -104,19 +103,15 @@ static CHIP_ERROR BrowseHandler(int argc, char ** argv)

static CHIP_ERROR DnsHandler(int argc, char ** argv)
{
if (!isResolverStarted)
{
chip::Mdns::Resolver::Instance().StartResolver(&chip::DeviceLayer::InetLayer, chip::Mdns::kMdnsPort);
chip::Mdns::Resolver::Instance().SetResolverDelegate(&sDnsShellResolverDelegate);

isResolverStarted = true;
}

if (argc == 0)
{
DnsHelpHandler(argc, argv);
return CHIP_NO_ERROR;
}

chip::Mdns::Resolver::Instance().StartResolver(&chip::DeviceLayer::InetLayer, chip::Mdns::kMdnsPort);
chip::Mdns::Resolver::Instance().SetResolverDelegate(&sDnsShellResolverDelegate);

return sShellDnsSubcommands.ExecCommand(argc, argv);
}

Expand Down

0 comments on commit aded3bb

Please sign in to comment.