1195972f6Sopenharmony_ciFrom be541628552ccc3a8dcd3c6ad6e5a1aed07c4928 Mon Sep 17 00:00:00 2001
2195972f6Sopenharmony_ciFrom: wuchangsheng <wuchangsheng2@huawei.com>
3195972f6Sopenharmony_ciDate: Sat, 3 Dec 2022 20:35:34 +0800
4195972f6Sopenharmony_ciSubject: [PATCH 2/2] fix app thread write fail
5195972f6Sopenharmony_ci
6195972f6Sopenharmony_ci---
7195972f6Sopenharmony_ci src/core/tcp_out.c      |  2 +-
8195972f6Sopenharmony_ci src/include/lwip/pbuf.h |  3 +++
9195972f6Sopenharmony_ci src/include/lwipsock.h  | 33 +++++++++++++++++++++++----------
10195972f6Sopenharmony_ci 3 files changed, 27 insertions(+), 11 deletions(-)
11195972f6Sopenharmony_ci
12195972f6Sopenharmony_cidiff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
13195972f6Sopenharmony_ciindex ee6f40b..f53750b 100644
14195972f6Sopenharmony_ci--- a/src/core/tcp_out.c
15195972f6Sopenharmony_ci+++ b/src/core/tcp_out.c
16195972f6Sopenharmony_ci@@ -763,7 +763,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
17195972f6Sopenharmony_ci 
18195972f6Sopenharmony_ci     pos += seglen;
19195972f6Sopenharmony_ci #if USE_LIBOS
20195972f6Sopenharmony_ci-    write_lwip_over((struct lwip_sock*)arg, 1);
21195972f6Sopenharmony_ci+    write_lwip_over((struct lwip_sock*)arg);
22195972f6Sopenharmony_ci #endif
23195972f6Sopenharmony_ci   }
24195972f6Sopenharmony_ci 
25195972f6Sopenharmony_cidiff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h
26195972f6Sopenharmony_ciindex ef879da..10e2af9 100644
27195972f6Sopenharmony_ci--- a/src/include/lwip/pbuf.h
28195972f6Sopenharmony_ci+++ b/src/include/lwip/pbuf.h
29195972f6Sopenharmony_ci@@ -231,6 +231,9 @@ struct pbuf {
30195972f6Sopenharmony_ci   u64_t l4_len:8;
31195972f6Sopenharmony_ci   u16_t header_off;
32195972f6Sopenharmony_ci   u8_t rexmit;
33195972f6Sopenharmony_ci+  u8_t in_write;
34195972f6Sopenharmony_ci+  u8_t head;
35195972f6Sopenharmony_ci+  struct pbuf *last;
36195972f6Sopenharmony_ci #endif /* USE_LIBOS CHECKSUM_OFFLOAD_SWITCH */
37195972f6Sopenharmony_ci 
38195972f6Sopenharmony_ci   /** In case the user needs to store data custom data on a pbuf */
39195972f6Sopenharmony_cidiff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
40195972f6Sopenharmony_ciindex 2ffb077..f919330 100644
41195972f6Sopenharmony_ci--- a/src/include/lwipsock.h
42195972f6Sopenharmony_ci+++ b/src/include/lwipsock.h
43195972f6Sopenharmony_ci@@ -93,17 +93,30 @@ struct lwip_sock {
44195972f6Sopenharmony_ci #endif
45195972f6Sopenharmony_ci 
46195972f6Sopenharmony_ci #if USE_LIBOS
47195972f6Sopenharmony_ci-  struct pbuf *send_lastdata;
48195972f6Sopenharmony_ci-  uint16_t send_datalen;
49195972f6Sopenharmony_ci-  volatile uint32_t events __rte_cache_aligned; /* available events */
50195972f6Sopenharmony_ci-  struct pbuf *recv_lastdata __rte_cache_aligned; /* unread data in one pbuf */
51195972f6Sopenharmony_ci-  struct list_node recv_list __rte_cache_aligned;
52195972f6Sopenharmony_ci-  struct list_node event_list __rte_cache_aligned;
53195972f6Sopenharmony_ci-  struct list_node send_list __rte_cache_aligned;
54195972f6Sopenharmony_ci-  uint32_t in_send __rte_cache_aligned; /* avoid sock too much send rpc msg*/
55195972f6Sopenharmony_ci+  char pad0 __rte_cache_aligned;
56195972f6Sopenharmony_ci+  /* app thread use */
57195972f6Sopenharmony_ci+  struct pbuf *recv_lastdata; /* unread data in one pbuf */
58195972f6Sopenharmony_ci+  uint16_t remain_len;
59195972f6Sopenharmony_ci   uint32_t epoll_events; /* registered events, EPOLLONESHOT write frequently */
60195972f6Sopenharmony_ci-  char pad __rte_cache_aligned;
61195972f6Sopenharmony_ci+  volatile uint32_t events; /* available events */
62195972f6Sopenharmony_ci+  struct list_node event_list;
63195972f6Sopenharmony_ci+
64195972f6Sopenharmony_ci+  char pad1 __rte_cache_aligned;
65195972f6Sopenharmony_ci+  /* app and stack thread all use */
66195972f6Sopenharmony_ci+  uint32_t in_send; /* avoid sock too much send rpc msg*/
67195972f6Sopenharmony_ci+  pthread_spinlock_t sock_lock;
68195972f6Sopenharmony_ci+
69195972f6Sopenharmony_ci+  char pad2 __rte_cache_aligned;
70195972f6Sopenharmony_ci+  /* stack thread all use */
71195972f6Sopenharmony_ci+  struct list_node recv_list;
72195972f6Sopenharmony_ci+  struct list_node send_list;
73195972f6Sopenharmony_ci+  struct pbuf *send_lastdata;
74195972f6Sopenharmony_ci+  struct pbuf *send_pre_del;
75195972f6Sopenharmony_ci+  uint64_t recv_all;
76195972f6Sopenharmony_ci+  uint64_t send_all;
77195972f6Sopenharmony_ci 
78195972f6Sopenharmony_ci+  char pad3 __rte_cache_aligned;
79195972f6Sopenharmony_ci+  /* nerver change */
80195972f6Sopenharmony_ci   struct wakeup_poll *wakeup;
81195972f6Sopenharmony_ci   epoll_data_t ep_data;
82195972f6Sopenharmony_ci   struct lwip_sock *listen_next; /* listenfd list */
83195972f6Sopenharmony_ci@@ -131,7 +144,7 @@ extern ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apifla
84195972f6Sopenharmony_ci extern struct pbuf *write_lwip_data(struct lwip_sock *sock, uint16_t remain_size, uint8_t *apiflags);
85195972f6Sopenharmony_ci extern void gazelle_init_sock(int32_t fd);
86195972f6Sopenharmony_ci extern void gazelle_clean_sock(int32_t fd);
87195972f6Sopenharmony_ci-extern void write_lwip_over(struct lwip_sock *sock, uint32_t n);
88195972f6Sopenharmony_ci+extern void write_lwip_over(struct lwip_sock *sock);
89195972f6Sopenharmony_ci #endif /* USE_LIBOS */
90195972f6Sopenharmony_ci 
91195972f6Sopenharmony_ci struct lwip_sock *get_socket(int s);
92195972f6Sopenharmony_ci-- 
93195972f6Sopenharmony_ci2.8.4.windows.1
94195972f6Sopenharmony_ci
95