1
0
Fork 0
forked from nuttx/nuttx-update

net/tcp/sendfile: removed excessive overwrites of conn->sndseq

(conn->sndseq was updated in multiple places that was unreasonable and complicated).
This optimization is the same as it was done for tcp_send_unbuffered.
This commit is contained in:
Alexander Lunev 2022-01-21 00:44:30 +03:00 committed by Xiang Xiao
parent 9061c92ec8
commit eec94132c4
2 changed files with 18 additions and 31 deletions

View file

@ -684,9 +684,7 @@ found:
{
uint32_t unackseq;
uint32_t ackseq;
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
uint32_t sndseq;
#endif
/* The next sequence number is equal to the current sequence
* number (sndseq) plus the size of the outstanding, unacknowledged
* data (tx_unacked).
@ -748,19 +746,24 @@ found:
}
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
/* Update sequence number to the unacknowledge sequence number. If
* there is still outstanding, unacknowledged data, then this will
* be beyond ackseq.
*/
sndseq = tcp_getsequence(conn->sndseq);
if (TCP_SEQ_LT(sndseq, ackseq))
#ifdef CONFIG_NET_SENDFILE
if (!conn->sendfile)
#endif
{
ninfo("sndseq: %08" PRIx32 "->%08" PRIx32
" unackseq: %08" PRIx32 " new tx_unacked: %" PRId32 "\n",
tcp_getsequence(conn->sndseq), ackseq, unackseq,
(uint32_t)conn->tx_unacked);
tcp_setsequence(conn->sndseq, ackseq);
/* Update sequence number to the unacknowledge sequence number. If
* there is still outstanding, unacknowledged data, then this will
* be beyond ackseq.
*/
uint32_t sndseq = tcp_getsequence(conn->sndseq);
if (TCP_SEQ_LT(sndseq, ackseq))
{
ninfo("sndseq: %08" PRIx32 "->%08" PRIx32
" unackseq: %08" PRIx32 " new tx_unacked: %" PRIu32 "\n",
tcp_getsequence(conn->sndseq), ackseq, unackseq,
(uint32_t)conn->tx_unacked);
tcp_setsequence(conn->sndseq, ackseq);
}
}
#endif

View file

@ -371,8 +371,6 @@ static uint16_t sendfile_eventhandler(FAR struct net_driver_s *dev,
if ((pstate->snd_sent - pstate->snd_acked + sndlen) < conn->snd_wnd)
{
uint32_t seqno;
/* Then set-up to send that amount of data. (this won't actually
* happen until the polling cycle completes).
*/
@ -396,20 +394,6 @@ static uint16_t sendfile_eventhandler(FAR struct net_driver_s *dev,
dev->d_sndlen = sndlen;
/* Set the sequence number for this packet. NOTE: The network
* updates sndseq on recept of ACK *before* this function is
* called. In that case sndseq will point to the next
* unacknowledge byte (which might have already been sent). We
* will overwrite the value of sndseq here before the packet is
* sent.
*/
seqno = pstate->snd_sent + pstate->snd_isn;
ninfo("SEND: sndseq %08" PRIx32 "->%08" PRIx32 " len: %d\n",
tcp_getsequence(conn->sndseq), seqno, ret);
tcp_setsequence(conn->sndseq, seqno);
/* Notify the device driver of the availability of TX data */
sendfile_txnotify(psock, conn);