gazelle/0005-fix-LD_PRELOAD.patch
jiangheng 06f81f5a16 fix gazelle test issue
(cherry picked from commit 0fb1ee99ffc056f82e79ae3fb3b97f5ad4473dee)
2022-03-16 23:06:01 +08:00

32 lines
955 B
Diff

From ff74c402d0502797fe4411178882bb3cb8e3ddd9 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng12@huawei.com>
Date: Mon, 7 Mar 2022 23:30:12 +0800
Subject: [PATCH 05/34] fix LD_PRELOAD
---
src/lstack/api/lstack_wrap.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index 7804ce9..6ee5639 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -44,6 +44,14 @@ enum KERNEL_LWIP_PATH {
static inline enum KERNEL_LWIP_PATH select_path(int fd)
{
+ if (posix_api == NULL) {
+ /* link liblstack.so using LD_PRELOAD mode will read liblstack.so,
+ poisx_api need to be initialized here */
+ if (posix_api_init() != 0) {
+ LSTACK_PRE_LOG(LSTACK_ERR, "posix_api_init failed\n");
+ }
+ return PATH_KERNEL;
+ }
struct lwip_sock *sock = posix_api->get_socket(fd);
/* AF_UNIX case */
--
1.8.3.1