mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-26 03:16:18 +00:00
tcp: remove extra seg == NULL checks
In tcp_output() there were a number of blocks of code performing duplicate checks of 'if (seg == NULL)'. This combines them together to reduce duplicate checks TCP_OUTPUT_DEBUG and TCP_CWND_DEBUG also don't need to be guarded by #if/#endif since the LWIP_DEBUGF infrastructure already compiles them out when LWIP_DEBUG is not defined
This commit is contained in:
parent
5ea7f507c3
commit
6fa5d02435
@ -1139,18 +1139,15 @@ tcp_output(struct tcp_pcb *pcb)
|
|||||||
return tcp_send_empty_ack(pcb);
|
return tcp_send_empty_ack(pcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TCP_OUTPUT_DEBUG
|
|
||||||
if (seg == NULL) {
|
if (seg == NULL) {
|
||||||
LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n",
|
LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n",
|
||||||
(void*)pcb->unsent));
|
(void*)pcb->unsent));
|
||||||
}
|
|
||||||
#endif /* TCP_OUTPUT_DEBUG */
|
|
||||||
#if TCP_CWND_DEBUG
|
|
||||||
if (seg == NULL) {
|
|
||||||
LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"TCPWNDSIZE_F
|
LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"TCPWNDSIZE_F
|
||||||
", cwnd %"TCPWNDSIZE_F", wnd %"U32_F
|
", cwnd %"TCPWNDSIZE_F", wnd %"U32_F
|
||||||
", seg == NULL, ack %"U32_F"\n",
|
", seg == NULL, ack %"U32_F"\n",
|
||||||
pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack));
|
pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack));
|
||||||
|
/* nothing to send: shortcut out of here */
|
||||||
|
goto output_done;
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(TCP_CWND_DEBUG,
|
LWIP_DEBUGF(TCP_CWND_DEBUG,
|
||||||
("tcp_output: snd_wnd %"TCPWNDSIZE_F", cwnd %"TCPWNDSIZE_F", wnd %"U32_F
|
("tcp_output: snd_wnd %"TCPWNDSIZE_F", cwnd %"TCPWNDSIZE_F", wnd %"U32_F
|
||||||
@ -1159,12 +1156,6 @@ tcp_output(struct tcp_pcb *pcb)
|
|||||||
lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len,
|
lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len,
|
||||||
lwip_ntohl(seg->tcphdr->seqno), pcb->lastack));
|
lwip_ntohl(seg->tcphdr->seqno), pcb->lastack));
|
||||||
}
|
}
|
||||||
#endif /* TCP_CWND_DEBUG */
|
|
||||||
|
|
||||||
if (seg == NULL) {
|
|
||||||
/* nothing to send: shortcut out of here */
|
|
||||||
goto output_done;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* useg should point to last segment on unacked queue */
|
/* useg should point to last segment on unacked queue */
|
||||||
useg = pcb->unacked;
|
useg = pcb->unacked;
|
||||||
@ -1194,8 +1185,7 @@ tcp_output(struct tcp_pcb *pcb)
|
|||||||
* subsequent window update is reliably received. With the goal of being lightweight,
|
* subsequent window update is reliably received. With the goal of being lightweight,
|
||||||
* we avoid splitting the unsent segment and treat the window as already zero.
|
* we avoid splitting the unsent segment and treat the window as already zero.
|
||||||
*/
|
*/
|
||||||
if (seg != NULL &&
|
if (lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd &&
|
||||||
lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd &&
|
|
||||||
wnd > 0 && wnd == pcb->snd_wnd && pcb->unacked == NULL) {
|
wnd > 0 && wnd == pcb->snd_wnd && pcb->unacked == NULL) {
|
||||||
/* Start the persist timer */
|
/* Start the persist timer */
|
||||||
if (pcb->persist_backoff == 0) {
|
if (pcb->persist_backoff == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user