fix(connectivity_plus): prevent Linux client leaks#3929
Open
Kibiandkimi wants to merge 1 commit into
Open
Conversation
Track each NetworkManager client and its property subscription as one session. Detach sessions synchronously on cancellation, wait for in-flight connects before closing, and close temporary clients on errors. Add regression tests for error cleanup, subscription cancellation, and rapid resubscription.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix the Linux
NetworkManagerClientlifecycle when connectivity listeners are canceled and immediately re-subscribed.StreamController.broadcastdoes not wait for an asynchronousonCancelcallback. The previous implementation accessed the shared_clienton both sides ofawaitcalls, so a new listener could reuse a client that was still closing, while an older listener setup could later dereference a cleared client. Closing aNetworkManagerClientbefore its pending connection finishes can also leave the subsequently opened system D-Bus connection unclosed. In addition, thepropertiesChangedsubscription was not retained or canceled.This change:
checkConnectivityon error paths as well.The regression tests deterministically cover error cleanup, property-subscription cleanup, and cancellation/re-subscription while a connection is pending.
Related Issues
None.
Checklist
CHANGELOG.mdnor the plugin version inpubspec.yamlfiles.flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
!in the title as explained in Conventional Commits).Validation
connectivity_pluspackagesconnectivity_plus,connectivity_plus_platform_interface, and the exampleconnectivity_plusandconnectivity_plus_platform_interfaceNetworkManagerintegration smoke test