Skip to content

Commit

Permalink
fix mdns leak on android (#15292)
Browse files Browse the repository at this point in the history
* fix removeServices exception, we missed clear registrationListeners

* fix restyled-io and ci errors

* remove try catch

* fix restyled-io and ci errors
  • Loading branch information
xylophone21 authored and pull[bot] committed Aug 21, 2023
1 parent b19f141 commit 3721928
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,31 @@ public void onUnregistrationFailed(NsdServiceInfo serviceInfo, int errorCode) {

@Override
public void onServiceRegistered(NsdServiceInfo serviceInfo) {
Log.i(TAG, "service " + serviceInfo.getServiceName() + " onServiceRegistered");
Log.i(
TAG,
"service " + serviceInfo.getServiceName() + "(" + this + ") onServiceRegistered");
}

@Override
public void onServiceUnregistered(NsdServiceInfo serviceInfo) {
Log.i(TAG, "service " + serviceInfo.getServiceName() + " onServiceRegistered");
Log.i(
TAG,
"service " + serviceInfo.getServiceName() + "(" + this + ") onServiceUnregistered");
}
};
registrationListeners.add(registrationListener);

nsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, registrationListener);
Log.d(TAG, "publish " + registrationListener + " count = " + registrationListeners.size());
}

@Override
public void removeServices() {
Log.d(TAG, "removeServices: ");
for (NsdManager.RegistrationListener l : registrationListeners) {
Log.i(TAG, "Remove " + l);
nsdManager.unregisterService(l);
}
registrationListeners.clear();
}
}

0 comments on commit 3721928

Please sign in to comment.