eycorsican / netstack-lwip

57 stars 41 forks source link

Fix the issue where TcpStream sometimes doesn't reach EOF #14

Closed SongXiaoXi closed 2 months ago

SongXiaoXi commented 2 months ago

This PR addresses an issue related to EOF detection in tcpstream. According to the AsyncRead::poll_read documentation, buf.filled().len() remains unchanged when EOF is reached. However, in scenarios where the read_rx contains a sequence like {["blabla"], []}, the poll_read method returns Poll::Ready(Ok(())) with a changed buf.filled().len(). This leads to the subsequent poll_read call getting stuck in poll_recv until a stream error occurs. The proposed changes improve the EOF detection mechanism to prevent this unintended behavior and ensure proper stream termination.