Commit 9d7c3f05 authored by David Goulet's avatar David Goulet
Browse files

socket: Used the unfilled section properly



Signed-off-by: default avatarDavid Goulet <dgoulet@ev0ke.net>
parent 0a0707b2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ impl AsyncRead for TcpSocket {
    ) -> Poll<std::io::Result<()>> {
        self.with(|s| match s.can_recv() {
            true => {
                let rbuf = s.recv(|b| (buf.remaining(), b));
                let rbuf = s.recv_slice(buf.initialize_unfilled());
                match rbuf {
                    Err(e) => {
                        return Poll::Ready(Err(std::io::Error::new(
@@ -128,9 +128,9 @@ impl AsyncRead for TcpSocket {
                            format!("{}", e),
                        )))
                    }
                    Ok(b) => {
                        if b.len() > 0 {
                            buf.put_slice(b);
                    Ok(n) => {
                        if n > 0 {
                            buf.set_filled(n);
                            Poll::Ready(Ok(()))
                        } else {
                            s.register_recv_waker(cx.waker());