Skip to content

Commit

Permalink
[darwin] Update DnssdHostNameRegistrar to use the network framework i… (
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored and pull[bot] committed Oct 11, 2023
1 parent bbb7bef commit 2116981
Show file tree
Hide file tree
Showing 7 changed files with 356 additions and 213 deletions.
23 changes: 23 additions & 0 deletions scripts/tests/chiptest/lsan-mac-suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,26 @@ leak:ERR_get_state

# TODO: https://github.com/project-chip/connectedhomeip/issues/22333
leak:[MTRBaseCluster* subscribeAttribute*WithParams:subscriptionEstablished:reportHandler:]

#TODO: Figure out why nw_path_monitor_create leaks. The leak can be reproduced using:
# -- testFile.cpp
#
##include <Network/Network.h>
#
#int main(int argc, char **argv) {
# auto monitor = nw_path_monitor_create();
# nw_release(monitor);
# return 0;
#}
#
# -- testFile.mm (with -fobj-arc)
##include <Network/Network.h>
#
#int main(int argc, char **argv) {
# __auto_type monitor = nw_path_monitor_create();
# return 0;
#}
leak:nw_path_monitor_create

# TODO: See the previous comment about nw_path_monitor_create, since it also applies to nw_path_monitor_start
leak:nw_path_monitor_start
1 change: 1 addition & 0 deletions src/platform/Darwin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ config("darwin_config") {
"CoreFoundation.framework",
"CoreBluetooth.framework",
"Foundation.framework",
"Network.framework",
]

if (current_os == "mac") {
Expand Down
19 changes: 3 additions & 16 deletions src/platform/Darwin/DnssdContexts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,23 +272,10 @@ void RegisterContext::DispatchSuccess()
{
std::string typeWithoutSubTypes = GetFullTypeWithoutSubTypes(mType);
callback(context, typeWithoutSubTypes.c_str(), mInstanceName.c_str(), CHIP_NO_ERROR);
}

RegisterRecordContext::RegisterRecordContext(RegisterContext * context)
{
type = ContextType::RegisterRecord;
mRegisterContext = context;
}

void RegisterRecordContext::DispatchFailure(DNSServiceErrorType err)
{
mRegisterContext->Finalize(err);
MdnsContexts::GetInstance().Remove(this);
}

void RegisterRecordContext::DispatchSuccess()
{
mRegisterContext->Finalize();
// Once a service has been properly published it is normally unreachable because the hostname has not yet been
// registered against the dns daemon. Register the records mapping the hostname to our IP.
mHostNameRegistrar.Register();
}

BrowseContext::BrowseContext(void * cbContext, DnssdBrowseCallback cb, DnssdServiceProtocol cbContextProtocol)
Expand Down
Loading

0 comments on commit 2116981

Please sign in to comment.