-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
ConnectToPort() needs to Dup() its VirtioSocketConnection #54
Comments
I think we should fix this problem to use |
I looked at |
Currently, newVirtioSocketConnection manually sets its objc file descriptor to non-blocking, calls dup() on it, ... so that it matches what go expects from a file descriptor. go provides a helper doing all of this for us: net.FileConn() This commit makes use of that helper. This will allow for more code simplifications in the next commits. However this removes vz.VirtioSocketConnection.FileDescriptor() since the file descriptor was created internally by net.FileConn(). It would be possible to keep it, but I'm not sure it's really useful. It would be more consistent with other go APIs to add a File() method if we want to expose this. One side-effect of this change is to fix connections returned by ConnectToPort. At the moment, they are missing a call to Dup() for the file descriptor they use. Without this, their file descriptor is closed too early, and the connection cannot be used. This fixes Code-Hex#54
I've tried this, this solves this bug, and this allows for some nice code simplifications. I've put these changes in https://github.com/cfergeau/vz/tree/vsock-upstream |
@cfergeau Exactly, I want the code but a little bit needs to fix a point. |
Describe the bug
The VirtioSocketConnection created through ConnectToPort() is closed after its completion handler returns.
To Reproduce
cfergeau@fd9f5cc
Expected behavior
The VirtioSocketConnection created through ConnectToPort() can be used outside of its completion hander.
Environment (please complete the following information):
Additional context
#53 has a proposed fix for this
The text was updated successfully, but these errors were encountered: