From c91f1d05c65526fe250cf5e5c32f9038721bc1d5 Mon Sep 17 00:00:00 2001 From: yangchen Date: Mon, 25 Dec 2023 12:39:56 +0800 Subject: [PATCH] tcp_send_fin: add the fin to the last unsent segment --- src/core/tcp_out.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c index 137e3cf..e5c407e 100644 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -1195,8 +1195,8 @@ tcp_send_fin(struct tcp_pcb *pcb) LWIP_ASSERT("tcp_send_fin: invalid pcb", pcb != NULL); /* first, try to add the fin to the last unsent segment */ - if (pcb->unsent != NULL) { - struct tcp_seg *last_unsent = pcb->unsent; + if (pcb->last_unsent != NULL) { + struct tcp_seg *last_unsent = pcb->last_unsent; if ((TCPH_FLAGS(last_unsent->tcphdr) & (TCP_SYN | TCP_FIN | TCP_RST)) == 0) { /* no SYN/FIN/RST flag in the header, we can add the FIN flag */ -- 2.33.0