From 544bf45ec99c853ad5e9ec2607669df01b4e0572 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng12@huawei.com>
Date: Mon, 7 Mar 2022 21:06:39 +0800
Subject: [PATCH] exec gazelle_init_sock() before read event

---
 src/api/sockets.c      | 1 +
 src/include/lwipsock.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/api/sockets.c b/src/api/sockets.c
index 4b682f3..21de5d9 100644
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -763,6 +763,7 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
   }
 #if USE_LIBOS
   LWIP_ASSERT("invalid socket index", (newsock >= LWIP_SOCKET_OFFSET) && (newsock < sockets_num + LWIP_SOCKET_OFFSET));
+  gazelle_init_sock(newsock);
 #else
   LWIP_ASSERT("invalid socket index", (newsock >= LWIP_SOCKET_OFFSET) && (newsock < NUM_SOCKETS + LWIP_SOCKET_OFFSET));
 #endif /* USE_LIBOS */
diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
index e2519ff..355bf47 100644
--- a/src/include/lwipsock.h
+++ b/src/include/lwipsock.h
@@ -157,6 +157,7 @@ get_socket_without_errno(int s)
 extern void add_recv_list(int32_t fd);
 extern ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags);
 extern void gazelle_clean_sock(int32_t fd);
+extern void gazelle_init_sock(int32_t fd);
 #endif /* USE_LIBOS */
 
 struct lwip_sock *get_socket(int s);
-- 
1.8.3.1

