Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tcp][RFC] Deliver data only after updating TCP state
Michael suggested something like: =============================================================== struct list_head received = LIST_HEAD_INIT ( received ); ... while ( ! list_empty ( &tcp->rx_queue ) ) { ... tcp_rx_data ( tcp, seq, iob_disown ( iobuf ), &received ); ... } list_for_each_entry_safe ( iobuf, tmp, &received, list ) { // deliver iobuf via xfer_deliver_iob() } if ( tcp->state & TCP_STATE_RCVD ( TCP_FIN ) ) tcp_close ( tcp, 0 ); =============================================================== But after some thought I think making the change like this commit can have same behavior, but simplified by not using extra queue. Which can also save some code size. In this patch: 1. We call xfer_deliver_iob() after fully updated/handled received TCP state. In which to have better timing that upper-layer protocol might call tcp_xfer_close() to initiate a shutdown, or sending extra data. 2. We move tcp_close() out from tcp_rx_fin() because tcp_close() nullified the xfer interface. It'll cause error to call xfer_deliver_iob() after tcp_rx_fin(). (So that I proposed an idea to clean up tcp_close(), I'll post it in later commit.)
- Loading branch information