-
Notifications
You must be signed in to change notification settings - Fork 87
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
return error also in the closing state #881
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should return Ok(0)
in both cases.
From Read::read
:
If n is 0, then it can indicate one of two scenarios:
- This reader has reached its “end of file” and will likely no longer be able to produce bytes. Note that this does not mean that the reader will always no longer be able to produce bytes. As an example, on Linux, this method will call the recv syscall for a TcpStream, where returning zero indicates the connection was shut down correctly. While for File, it is possible to reach the end of file and get zero as result, but if more data is appended to the file, future calls to read will return more data.
- The buffer specified was 0 bytes in length.
From Write::write
:
A return value of Ok(0) typically means that the underlying object is no longer able to accept bytes and will likely not be able to in the future as well, or that the buffer provided is empty.
Note that the example from the issue does not result in an error on Linux either.
You are right. I fixed it. |
If smoltcp receives a FIN message, the socket changes the state to the `closing`, but the socket is still active. To close the socket, the kernel returns a error if the socket is in the closing state. The PR should solve issue hermit-os#880
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we really return an error on FIN-WAIT-1 etc.? It might be better to not match against the TCP state directly and instead use may_send
and may_receive
. What do you think?
If smoltcp receives a FIN message, the socket changes the state to the
closing
, but the socket is still active. To close the socket, the kernel returns a error if the socket is in the closing state.The PR should solve issue #880