1From 0c7d7ad7f9a79a557a867a6009aa2aac067d454e Mon Sep 17 00:00:00 2001 2From: wuchangsheng <wuchangsheng2@huawei.com> 3Date: Thu, 6 Oct 2022 21:07:12 +0800 4Subject: [PATCH] fix free pbuf miss data 5 6--- 7 src/core/tcp_out.c | 18 ++++++++++++++++++ 8 src/include/lwipopts.h | 2 +- 9 2 files changed, 19 insertions(+), 1 deletion(-) 10 11diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c 12index dd780d3..2834ba3 100644 13--- a/src/core/tcp_out.c 14+++ b/src/core/tcp_out.c 15@@ -682,11 +682,24 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) 16 if (queuelen > LWIP_MIN(TCP_SND_QUEUELEN, TCP_SNDQUEUELEN_OVERFLOW)) { 17 LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("tcp_write: queue too long %"U16_F" (%d)\n", 18 queuelen, (int)TCP_SND_QUEUELEN)); 19+#if USE_LIBOS 20+ if (pos > 0) { 21+ queuelen -= pbuf_clen(p); 22+ break; 23+ } 24+#else 25 pbuf_free(p); 26+#endif 27 goto memerr; 28 } 29 30 if ((seg = tcp_create_segment(pcb, p, 0, pcb->snd_lbb + pos, optflags)) == NULL) { 31+#if USE_LIBOS 32+ if (pos > 0) { 33+ queuelen -= pbuf_clen(p); 34+ break; 35+ } 36+#endif 37 goto memerr; 38 } 39 #if TCP_OVERSIZE_DBGCHECK 40@@ -714,6 +727,9 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) 41 lwip_ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg))); 42 43 pos += seglen; 44+#if USE_LIBOS 45+ write_lwip_over((struct lwip_sock*)arg, 1); 46+#endif 47 } 48 49 /* 50@@ -825,12 +841,14 @@ memerr: 51 tcp_set_flags(pcb, TF_NAGLEMEMERR); 52 TCP_STATS_INC(tcp.memerr); 53 54+#if !USE_LIBOS 55 if (concat_p != NULL) { 56 pbuf_free(concat_p); 57 } 58 if (queue != NULL) { 59 tcp_segs_free(queue); 60 } 61+#endif 62 if (pcb->snd_queuelen != 0) { 63 LWIP_ASSERT("tcp_write: valid queue length", pcb->unacked != NULL || 64 pcb->unsent != NULL); 65diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h 66index 75d3c74..7459991 100644 67--- a/src/include/lwipopts.h 68+++ b/src/include/lwipopts.h 69@@ -133,7 +133,7 @@ 70 71 #define USE_LIBOS 1 72 73-#define LWIP_DEBUG 1 74+//#define LWIP_DEBUG 1 75 76 #define LWIP_PERF 1 77 78-- 792.27.0 80 81