From a65c9583056863378dc7cc8878a1c584a8d90997 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 22 Sep 2022 23:18:06 +0200 Subject: [PATCH] [Darwin] Call ResetSharedConnection and not StartSharedConnection in src/platform/Darwin/DnssdHostNameRegistrar.cpp in order to properly unregister / register interfaces addresses (#22810) --- src/platform/Darwin/DnssdHostNameRegistrar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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));