Skip to content
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

implement TcpStream::peek methods #64

Closed
wants to merge 4 commits into from

Conversation

MarinPostma
Copy link
Contributor

This PR implements the TcpStream peek and poll_peek methods.

depends on #63

refactor `StreamSocket` by replacing the channel with a buffer of
segments, along with a slot for a waker.

`StreamSocket` exposes 2 methods: `poll_read_ready` and `try_read`
mimicking tokio in both API and behavior.
Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM just two questions

}

impl ReadHalf {
fn poll_read_priv(&mut self, cx: &mut Context<'_>, buf: &mut ReadBuf) -> Poll<Result<()>> {
if self.is_closed || buf.capacity() == 0 {
if buf.capacity() == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this check for closed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match host.tcp.socket_mut(&self.pair) {
Some(socket) => {
ready!(socket.poll_read_ready(cx));
unsafe {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it makes sense to break up the unsafe blocks to only the unsafe components instead of wrapping it all in one block. That said, I don't remember how we do it in tokio so this could be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the snippets I see in tokio, unsafe blocks seem to often contain whole blocks rather than single statements

@mcches
Copy link
Contributor

mcches commented May 24, 2023

Closing due to no activity.

@mcches mcches closed this May 24, 2023
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.

None yet

3 participants