Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Linux] Fix mDNSResolver memory leak #31709

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/controller/python/ChipDeviceController-Discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ PyChipError pychip_DeviceController_DiscoverCommissionableNodes(Controller::Devi
return ToPyChipError(devCtrl->DiscoverCommissionableNodes(filter));
}

PyChipError pychip_DeviceController_StopCommissionableDiscovery(Controller::DeviceCommissioner * devCtrl)
{
return ToPyChipError(devCtrl->StopCommissionableDiscovery());
}

void pychip_DeviceController_IterateDiscoveredCommissionableNodes(Controller::DeviceCommissioner * devCtrl,
IterateDiscoveredCommissionableNodesFunct cb)
{
Expand Down
7 changes: 7 additions & 0 deletions src/controller/python/chip/ChipDeviceCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@ def DiscoverCommissionableNodes(self, filterType: discovery.FilterType = discove
else:
time.sleep(timeoutSecond)

self._ChipStack.Call(
lambda: self._dmLib.pychip_DeviceController_StopCommissionableDiscovery(self.devCtrl)).raise_on_error()

return self.GetDiscoveredDevices()

def DiscoverCommissionableNodesLongDiscriminator(self, long_discriminator):
Expand Down Expand Up @@ -1567,6 +1570,10 @@ def _InitLib(self):
c_void_p, c_uint8, c_char_p]
self._dmLib.pychip_DeviceController_DiscoverCommissionableNodes.restype = PyChipError

self._dmLib.pychip_DeviceController_StopCommissionableDiscovery.argtypes = [
c_void_p]
self._dmLib.pychip_DeviceController_StopCommissionableDiscovery.restype = PyChipError

self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesLongDiscriminator.argtypes = [
c_void_p, c_uint16]
self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesLongDiscriminator.restype = PyChipError
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Linux/DnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ void MdnsAvahi::HandleResolve(AvahiServiceResolver * resolver, AvahiIfIndex inte
avahi_service_resolver_free(resolver);
context->mResolver = avahi_service_resolver_new(
context->mInstance->mClient, context->mInterface, context->mTransport, context->mName, context->mFullType.c_str(),
nullptr, context->mAddressType, static_cast<AvahiLookupFlags>(0), HandleResolve, context);
nullptr, context->mAddressType, static_cast<AvahiLookupFlags>(0), HandleResolve, userdata);
if (context->mResolver == nullptr)
{
ChipLogError(DeviceLayer, "Avahi resolve failed on retry");
Expand Down
Loading