-
Notifications
You must be signed in to change notification settings - Fork 312
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
Complete socketpair support #3442
Comments
I think this should follow the proposed "project" process: #3443. |
I wonder if there are libc compliance test suites that are licensed well enough for us to extract tests from |
Hi, I am planning to work on this first since it is related to #3448. I will send the link to the proposal here once I finished |
@rustbot claim |
Hmm I couldn't find any test for libc for now, if anyone knows where can I find one please let me know, thanks. Currently I imagine minimally the test should look like this (Note: they wrapped libc around their API, so it looks slightly different) #[test]
pub fn test_socketpair() {
use nix::sys::socket::{socketpair, AddressFamily, SockFlag, SockType};
use nix::unistd::{read, write};
let (fd1, fd2) = socketpair(
AddressFamily::Unix,
SockType::Stream,
None,
SockFlag::empty(),
)
.unwrap();
write(&fd1, b"hello").unwrap();
let mut buf = [0; 5];
read(fd2.as_raw_fd(), &mut buf).unwrap();
assert_eq!(&buf[..], b"hello");
}
//source: https://github.com/nix-rust/nix/blob/590ab4d5d0b6228f0529b036e4f8a42265ba6d31/test/sys/test_socket.rs#L311. I might add similar test in the proposal that I am going to send soon. |
This is the proposal for
Feel free to provide any ideas or suggestion especially for the buffer mechanism part. |
Why does it need to? Shouldn't the abstraction provided by the |
Left some comments,on the doc |
Yes, we should.
As Oli said: you "just" have to implement the |
Thanks! The API description is very helpful. I have left some comments. What is missing for me is a plan for how the Miri state looks like. In particular, the proposal should say what the fields of struct SocketPair {
write_buf: Rc<SocketBuf>,
read_buf: Rc<SocketBuf>,
} but that then raises the question of what the fields of |
FWIW, once this is done it should be fairly easy to also support |
After reading Besides, it is likely that |
Does tokio need non blocking sockets? I think no so yeah this can be left for later.
SOCK_DGRAM needs a pretty different implementation (we need to preserve message boundaries) so I think that is also out for now.
|
Yes, I just realised mio seems to support both FWIW, we might also need to provide support for "block with timeout" at some point too because apparently mio has them, tokio has related functions too :) But I will go through all the flags and what should we do with them again in detail once we start to discuss epoll.
Hmm, now I think about it, should we Footnotes
|
Yes, definitely. We don't currently support it. We should throw_unsup_format on everything we do not support. (The current shim is buggy in that it does not properly do this.)
I don't know what you mean by that. Does tokio set |
I see why it is important to
I didn't know // Recall that read looks like this:
ssize_t read(int fd, void* buffer, size_t length);
// Return number of bytes read, or -1 on error
Yes, both
Oh that's only for Footnotes |
Ah. In that case you probably should implement non-blocking sockets first -- i.e., store during socket creation whether the socket is blocking, and then in read/write, if we would have to block, It is up to you whether you want to implement support for blocking sockets at all, if it is not needed for tokio. |
I am only mentioning So to actually support
Footnotes |
Don't worry about running mio on macOS for now. That's going to be completely different anyway, it can't be using epoll. But the NONBLOCK check in the |
We pretend to implement
socketpair
, but that's a complete lie. Completing this however doesn't need any involvement with the rest of the epoll plans. We "just" need to allocate somewhere two buffers for the data to be sent between these two endpoints, and then wire up the read/write of the two sockets with the right buffers. This can be tested by directly usingsocketpair
/read
/write
.There's also #3231.
We can provide more detailed mentoring instructions if needed.
The text was updated successfully, but these errors were encountered: