[riot-notifications] [RIOT-OS/RIOT] [RFC] gnrc_tcp_recv(): fix connection closed by remote host not handled (#10899)
notifications at github.com
Sun Feb 3 16:07:41 CET 2019
After looking at the current implementation I think you found something there.
As you said the problem is that the caller is blocked in the recv()-call until the next data carrying packet arrives. If this packet doesn't arrive you get the error that your requested timeout. So far so good.
In cases where you read anything from the recv buffer and the last packet contained the FIN-Flag, it makes
no sense to wait for new Payload because the connection is terminated already.
I would suggest the following semantics for your fix:
The RFC says that even if the TCB is in the CLOSE-WAIT state, a recv-call must allow to read from the recv-buffer. At first I would check if the TCB is in the CLOSE-WAIT state. If so, try to read Data from the receive buffer. If it is empty (return code is 0) return an appropriate return code otherwise return the number of read bytes.
On the return code: Currently either the number of read bytes or an error code is returned, so using zero to indicate that the connection was closed is fine, although please update the documentation in the header file
because it is a small change in the semantics.
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications