fix(vsock): retain connection owner after handoff - #911
Open
stephenlclarke wants to merge 1 commit into
Open
Conversation
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.
Summary
Keep the Virtualization.framework VSOCK connection object alive after handing a duplicated descriptor to a
FileHandle.The existing handoff closed and released
VZVirtioSocketConnectionimmediately afterdup. Virtualization.framework owns the original descriptor and requires the connection object to remain alive; releasing it can invalidate transport state while callers are still using the duplicate.Associate the connection owner with the returned
FileHandle, for both accepted listener connections andfileHandle(closeWhenDone:). The owner is released when the handle is released, while callers retain the existing responsibility for closing the duplicated descriptor.Testing
swift test --filter VsockListenerTestsResult: 1 focused lifetime regression passed. It verifies the owner survives descriptor handoff and is released with the handle.
Compatibility
No public API or wire behavior changes. The association is private to the macOS implementation.