Conversation
efcec20 to
14b4026
Compare
hexagonal-sun
left a comment
There was a problem hiding this comment.
Looks good, some minor comments. Hopefully they'll fix things up nicely. One final point.. perhaps it's worth putting all this code under net, rather than socket? That seems to be the idiomatic name that most kernels use for this kind of code.
|
|
||
| impl TcpSocket { | ||
| pub fn new() -> Self { | ||
| let rx_buffer = SocketBuffer::new(vec![0; 4096]); |
There was a problem hiding this comment.
Rather than using the heap, maybe dedicate a ClaimedPage here.
There was a problem hiding this comment.
SocketBuffer needs something that can be converted into a ManagedSlice, so I have to give it an owned vec. Trying to give it a borrowed slice runs into issues because the slice would be given a lifetime of 'static
| handle, | ||
| local_endpoint: SpinLock::new(None), | ||
| backlogs: SpinLock::new(Vec::new()), | ||
| num_backlogs: AtomicUsize::new(0), |
There was a problem hiding this comment.
I'm not sure I quite get why we track this separately? Couldn't we call backlogs.len()?
There was a problem hiding this comment.
I was trying to reduce calls into the SpinLock for performance.
| } | ||
|
|
||
| #[async_trait] | ||
| impl SocketOps for UnixSocket { |
There was a problem hiding this comment.
I almost wonder whether we make a bit of an architectural change here and consider splitting the trait into two types.. a listening socket and a connected socket? Feels like this might make things easier.
There was a problem hiding this comment.
Then the registry would only contain listening sockets.
| if *self.rd_shutdown.lock_save_irq() { | ||
| return Ok(0); | ||
| } | ||
| self.inbox.copy_to_user(buf, count).await |
There was a problem hiding this comment.
Once thing to note, SeqPacket and Datagram sockets will not preserve message boundaries with the kbuf, it's just a stream of bytes; a perfect fit for Stream sockets.
We need to think about how we can preserve message boundaries.
d17077d to
e1b5869
Compare
# Conflicts: # Cargo.lock # Cargo.toml # libkernel/src/error.rs # usertest/src/main.rs
Implements socket syscalls (i.e.
socket,accept,connect,bind, etc.) and unix sockets. Also stubs out part of a TCP socket implementation.