From 6b097278f9d70f3cc976d7a7078447975de6a4b7 Mon Sep 17 00:00:00 2001
From: zhengjiebing <zhengjiebing_yewu@cmss.chinamobile.com>
Date: Mon, 29 Jul 2024 14:07:21 +0800
Subject: [PATCH] rtc: do_lwip_init_sock no need to create ring in rtc mode

---
 src/lstack/api/lstack_rtc_api.c | 8 --------
 src/lstack/core/lstack_lwip.c   | 9 +++++++++
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/lstack/api/lstack_rtc_api.c b/src/lstack/api/lstack_rtc_api.c
index ca0e7ec..e30718c 100644
--- a/src/lstack/api/lstack_rtc_api.c
+++ b/src/lstack/api/lstack_rtc_api.c
@@ -50,14 +50,6 @@ int rtc_socket(int domain, int type, int protocol)
     
     /* need call stack thread init function */
     ret = lwip_socket(domain, type, protocol);
-    if (ret >= 0) {
-        struct lwip_sock *sock = lwip_get_socket(ret);
-        sock->stack = get_protocol_stack();
-        sock->epoll_events = 0;
-        sock->events = 0;
-        sock->wakeup = NULL;
-        list_init_node(&sock->event_list);
-    }
     return ret;
 }
 
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 271e94f..4ea13ad 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -154,6 +154,15 @@ int do_lwip_init_sock(int32_t fd)
         return -1;
     }
 
+    if (get_global_cfg_params()->stack_mode_rtc) {
+        sock->stack = stack;
+        sock->epoll_events = 0;
+        sock->events = 0;
+        sock->wakeup = NULL;
+        list_init_node(&sock->event_list);
+        return 0;
+    }
+
     reset_sock_data(sock);
 
     sock->recv_ring = gazelle_ring_create_fast("sock_recv", SOCK_RECV_RING_SIZE, RING_F_SP_ENQ | RING_F_SC_DEQ);
-- 
2.33.0

