Skip to content

fix(vsock): retain connection owner after handoff - #911

Open
stephenlclarke wants to merge 1 commit into
apple:mainfrom
stephenlclarke:upstream/vsock-connection-ownership
Open

fix(vsock): retain connection owner after handoff#911
stephenlclarke wants to merge 1 commit into
apple:mainfrom
stephenlclarke:upstream/vsock-connection-ownership

Conversation

@stephenlclarke

Copy link
Copy Markdown
Contributor

Summary

Keep the Virtualization.framework VSOCK connection object alive after handing a duplicated descriptor to a FileHandle.

The existing handoff closed and released VZVirtioSocketConnection immediately after dup. 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 and fileHandle(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 VsockListenerTests

Result: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant