mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 18:14:53 +00:00
tcp_output: move useg assignment to right before segment while loop
There were a couple cases in-between that could cause an exit from tcp_output which don't use useg. With large send buffers, pcb->unacked may be large and calculating useg is wasted in these exit cases Some compilers may be re-ordering this already, but it doesn't hurt to correctly arrange the code
This commit is contained in:
parent
1d4ca0bff6
commit
28e519b72d
@ -1151,12 +1151,6 @@ tcp_output(struct tcp_pcb *pcb)
|
||||
lwip_ntohl(seg->tcphdr->seqno), pcb->lastack));
|
||||
}
|
||||
|
||||
/* useg should point to last segment on unacked queue */
|
||||
useg = pcb->unacked;
|
||||
if (useg != NULL) {
|
||||
for (; useg->next != NULL; useg = useg->next);
|
||||
}
|
||||
|
||||
netif = tcp_route(pcb, &pcb->local_ip, &pcb->remote_ip);
|
||||
if (netif == NULL) {
|
||||
return ERR_RTE;
|
||||
@ -1192,6 +1186,12 @@ tcp_output(struct tcp_pcb *pcb)
|
||||
}
|
||||
/* Stop persist timer, above conditions are not active */
|
||||
pcb->persist_backoff = 0;
|
||||
|
||||
/* useg should point to last segment on unacked queue */
|
||||
useg = pcb->unacked;
|
||||
if (useg != NULL) {
|
||||
for (; useg->next != NULL; useg = useg->next);
|
||||
}
|
||||
/* data available and window allows it to be sent? */
|
||||
while (seg != NULL &&
|
||||
lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) {
|
||||
|
Loading…
Reference in New Issue
Block a user