1From be541628552ccc3a8dcd3c6ad6e5a1aed07c4928 Mon Sep 17 00:00:00 2001 2From: wuchangsheng <wuchangsheng2@huawei.com> 3Date: Sat, 3 Dec 2022 20:35:34 +0800 4Subject: [PATCH 2/2] fix app thread write fail 5 6--- 7 src/core/tcp_out.c | 2 +- 8 src/include/lwip/pbuf.h | 3 +++ 9 src/include/lwipsock.h | 33 +++++++++++++++++++++++---------- 10 3 files changed, 27 insertions(+), 11 deletions(-) 11 12diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c 13index ee6f40b..f53750b 100644 14--- a/src/core/tcp_out.c 15+++ b/src/core/tcp_out.c 16@@ -763,7 +763,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) 17 18 pos += seglen; 19 #if USE_LIBOS 20- write_lwip_over((struct lwip_sock*)arg, 1); 21+ write_lwip_over((struct lwip_sock*)arg); 22 #endif 23 } 24 25diff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h 26index ef879da..10e2af9 100644 27--- a/src/include/lwip/pbuf.h 28+++ b/src/include/lwip/pbuf.h 29@@ -231,6 +231,9 @@ struct pbuf { 30 u64_t l4_len:8; 31 u16_t header_off; 32 u8_t rexmit; 33+ u8_t in_write; 34+ u8_t head; 35+ struct pbuf *last; 36 #endif /* USE_LIBOS CHECKSUM_OFFLOAD_SWITCH */ 37 38 /** In case the user needs to store data custom data on a pbuf */ 39diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h 40index 2ffb077..f919330 100644 41--- a/src/include/lwipsock.h 42+++ b/src/include/lwipsock.h 43@@ -93,17 +93,30 @@ struct lwip_sock { 44 #endif 45 46 #if USE_LIBOS 47- struct pbuf *send_lastdata; 48- uint16_t send_datalen; 49- volatile uint32_t events __rte_cache_aligned; /* available events */ 50- struct pbuf *recv_lastdata __rte_cache_aligned; /* unread data in one pbuf */ 51- struct list_node recv_list __rte_cache_aligned; 52- struct list_node event_list __rte_cache_aligned; 53- struct list_node send_list __rte_cache_aligned; 54- uint32_t in_send __rte_cache_aligned; /* avoid sock too much send rpc msg*/ 55+ char pad0 __rte_cache_aligned; 56+ /* app thread use */ 57+ struct pbuf *recv_lastdata; /* unread data in one pbuf */ 58+ uint16_t remain_len; 59 uint32_t epoll_events; /* registered events, EPOLLONESHOT write frequently */ 60- char pad __rte_cache_aligned; 61+ volatile uint32_t events; /* available events */ 62+ struct list_node event_list; 63+ 64+ char pad1 __rte_cache_aligned; 65+ /* app and stack thread all use */ 66+ uint32_t in_send; /* avoid sock too much send rpc msg*/ 67+ pthread_spinlock_t sock_lock; 68+ 69+ char pad2 __rte_cache_aligned; 70+ /* stack thread all use */ 71+ struct list_node recv_list; 72+ struct list_node send_list; 73+ struct pbuf *send_lastdata; 74+ struct pbuf *send_pre_del; 75+ uint64_t recv_all; 76+ uint64_t send_all; 77 78+ char pad3 __rte_cache_aligned; 79+ /* nerver change */ 80 struct wakeup_poll *wakeup; 81 epoll_data_t ep_data; 82 struct lwip_sock *listen_next; /* listenfd list */ 83@@ -131,7 +144,7 @@ extern ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apifla 84 extern struct pbuf *write_lwip_data(struct lwip_sock *sock, uint16_t remain_size, uint8_t *apiflags); 85 extern void gazelle_init_sock(int32_t fd); 86 extern void gazelle_clean_sock(int32_t fd); 87-extern void write_lwip_over(struct lwip_sock *sock, uint32_t n); 88+extern void write_lwip_over(struct lwip_sock *sock); 89 #endif /* USE_LIBOS */ 90 91 struct lwip_sock *get_socket(int s); 92-- 932.8.4.windows.1 94 95