1195972f6Sopenharmony_ciFrom fc2a5b52f7d9f02eb43931414767635e5cf4c8c1 Mon Sep 17 00:00:00 2001
2195972f6Sopenharmony_ciFrom: jiangheng <jiangheng14@huawei.com>
3195972f6Sopenharmony_ciDate: Tue, 11 Oct 2022 21:47:24 +0800
4195972f6Sopenharmony_ciSubject: [PATCH] alloc socket fail clean sock
5195972f6Sopenharmony_ci
6195972f6Sopenharmony_ci---
7195972f6Sopenharmony_ci src/api/sockets.c      | 3 +++
8195972f6Sopenharmony_ci src/include/lwipsock.h | 1 +
9195972f6Sopenharmony_ci 2 files changed, 4 insertions(+)
10195972f6Sopenharmony_ci
11195972f6Sopenharmony_cidiff --git a/src/api/sockets.c b/src/api/sockets.c
12195972f6Sopenharmony_ciindex 14f2b35..3552599 100644
13195972f6Sopenharmony_ci--- a/src/api/sockets.c
14195972f6Sopenharmony_ci+++ b/src/api/sockets.c
15195972f6Sopenharmony_ci@@ -598,6 +598,9 @@ alloc_socket(struct netconn *newconn, int accepted)
16195972f6Sopenharmony_ci     sockets[i].sendevent  = (NETCONNTYPE_GROUP(newconn->type) == NETCONN_TCP ? (accepted != 0) : 1);
17195972f6Sopenharmony_ci     sockets[i].errevent   = 0;
18195972f6Sopenharmony_ci     return i + LWIP_SOCKET_OFFSET;
19195972f6Sopenharmony_ci+  } else {
20195972f6Sopenharmony_ci+    lwip_close(i);
21195972f6Sopenharmony_ci+    gazelle_clean_sock(i);
22195972f6Sopenharmony_ci   }
23195972f6Sopenharmony_ci 
24195972f6Sopenharmony_ci err:
25195972f6Sopenharmony_cidiff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
26195972f6Sopenharmony_ciindex 912d471..2ffb077 100644
27195972f6Sopenharmony_ci--- a/src/include/lwipsock.h
28195972f6Sopenharmony_ci+++ b/src/include/lwipsock.h
29195972f6Sopenharmony_ci@@ -130,6 +130,7 @@ extern void add_recv_list(int32_t fd);
30195972f6Sopenharmony_ci extern ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags);
31195972f6Sopenharmony_ci extern struct pbuf *write_lwip_data(struct lwip_sock *sock, uint16_t remain_size, uint8_t *apiflags);
32195972f6Sopenharmony_ci extern void gazelle_init_sock(int32_t fd);
33195972f6Sopenharmony_ci+extern void gazelle_clean_sock(int32_t fd);
34195972f6Sopenharmony_ci extern void write_lwip_over(struct lwip_sock *sock, uint32_t n);
35195972f6Sopenharmony_ci #endif /* USE_LIBOS */
36195972f6Sopenharmony_ci 
37195972f6Sopenharmony_ci-- 
38195972f6Sopenharmony_ci2.23.0
39195972f6Sopenharmony_ci
40