listener,stream: add OwnedFd integration#72
Conversation
qwandor
left a comment
There was a problem hiding this comment.
Thanks! Would it make sense to implement the reverse conversion too? And what about VsockStream, and the synchronous versions of these in the vsock crate?
Sure! Happy to add those too, honestly I was just focus on "my" use-case (and this is all I need there) but it make sense to widen it a bit. I added the reverse conversion now. I'm happy to add the others too. Do you want them in separate PRs or in this PR? For the stream I would do something like: +impl FromRawFd for VsockStream {
+ unsafe fn from_raw_fd(fd: RawFd) -> Self {
+ Self::new(vsock::VsockStream::from_raw_fd(fd)).unwrap()
+ }
+}which mimics the VsockListener code - I assume the unwarp() there is okay here too (just like in VsockListener)? |
|
I've sent rust-vsock/vsock-rs#65 to add the equivalent conversions to the underlying vsock crate. Once that's released you should be able to update this to avoid the unsafe blocks. |
|
vsock 0.5.4 is now released, please update this change to use that. |
|
And you can go ahead and add the conversions for |
This commit makes working with OwnedFds easier by providing
implementations for
`From<OwnedFd> for Vsock{Listener,Stream}`
and
`From<Vsock{Listener,Stream}> for OwnedFd`
This is useful for e.g. socket-activated services that get
passed a fd and avoids the need for the caller to use the
unsafe FromRawFd.
Signed-off-by: Michael Vogt <michael@amutable.com>
With rust-vsock/tokio-vsock#72 being merged we can remove the unsafe block and use the From<OwnedFd> in the vsock listener code.
With rust-vsock/tokio-vsock#72 being merged we can remove the unsafe block and use the From<OwnedFd> in the vsock listener code.
With rust-vsock/tokio-vsock#72 being merged we can remove the unsafe block and use the From<OwnedFd> in the vsock listener code.
With rust-vsock/tokio-vsock#72 being merged we can remove the unsafe block and use the From<OwnedFd> in the vsock listener code.
With rust-vsock/tokio-vsock#72 being merged we can remove the unsafe block and use the From<OwnedFd> in the vsock listener code.
This commit makes working with OwnedFds easier by providing
implementations for
From<OwnedFd> for Vsock{Listener,Stream}and
From<Vsock{Listener,Stream}> for OwnedFdThis is useful for e.g. socket-activated services that get
passed a fd and avoids the need for the caller to use the
unsafe FromRawFd.