diff --git a/src/platform/Darwin/DnssdHostNameRegistrar.cpp b/src/platform/Darwin/DnssdHostNameRegistrar.cpp index a936521528f95d..a2415791d4aa4a 100644 --- a/src/platform/Darwin/DnssdHostNameRegistrar.cpp +++ b/src/platform/Darwin/DnssdHostNameRegistrar.cpp @@ -272,7 +272,7 @@ CHIP_ERROR HostNameRegistrar::Register() VerifyOrReturnError(!IsLocalOnly(), CHIP_NO_ERROR); return StartMonitorInterfaces(^(InetInterfacesVector inetInterfaces, Inet6InterfacesVector inet6Interfaces) { - ReturnOnFailure(StartSharedConnection()); + ReturnOnFailure(ResetSharedConnection()); RegisterInterfaces(inetInterfaces, kDNSServiceType_A); RegisterInterfaces(inet6Interfaces, kDNSServiceType_AAAA); }); @@ -355,6 +355,8 @@ void HostNameRegistrar::StopMonitorInterfaces() CHIP_ERROR HostNameRegistrar::StartSharedConnection() { + VerifyOrReturnError(mServiceRef == nullptr, CHIP_ERROR_INCORRECT_STATE); + auto err = DNSServiceCreateConnection(&mServiceRef); VerifyOrReturnValue(kDNSServiceErr_NoError == err, Error::ToChipError(err));