From 52fafeafd51ed5363081064076dff4ed276a99c1 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Thu, 22 Feb 2024 21:22:44 +0800
Subject: [PATCH] fix coreddump when stack setup failed in rtc mode

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

diff --git a/src/lstack/api/lstack_rtc_api.c b/src/lstack/api/lstack_rtc_api.c
index d29e51e..2e10e30 100644
--- a/src/lstack/api/lstack_rtc_api.c
+++ b/src/lstack/api/lstack_rtc_api.c
@@ -45,7 +45,7 @@ int rtc_socket(int domain, int type, int protocol)
     int ret;
 
     if (stack_setup_app_thread() < 0) {
-        LSTACK_EXIT(1, "stack_setup_app_thread failed!\n");
+        exit(1);
     }
     
     /* need call stack thread init function */
@@ -74,7 +74,7 @@ int rtc_shutdown(int fd, int how)
 int rtc_epoll_create(int flags)
 {
     if (stack_setup_app_thread() < 0) {
-        LSTACK_EXIT(1, "stack_setup_app_thread failed!\n");
+        exit(1);
     }
 
     return lstack_epoll_create(flags);
@@ -83,7 +83,7 @@ int rtc_epoll_create(int flags)
 int rtc_epoll_create1(int flags)
 {
     if (stack_setup_app_thread() < 0) {
-        LSTACK_EXIT(1, "stack_setup_app_thread failed!\n");
+        exit(1);
     }
 
     return lstack_epoll_create1(flags);
diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c
index 31fd91d..bd9ba8a 100644
--- a/src/lstack/core/lstack_init.c
+++ b/src/lstack/core/lstack_init.c
@@ -109,12 +109,11 @@ static int32_t check_process_conflict(void)
 
 void gazelle_exit(void)
 {
-    if (!get_global_cfg_params()->stack_mode_rtc) {
-        wrap_api_set_dummy();
-        /* 1: wait until app thread call send functio complete */
-        sleep(1);
-        stack_group_exit();
-    }
+    wrap_api_set_dummy();
+    /* 1: wait until app thread call send functio complete */
+    sleep(1);
+    stack_group_exit();
+
     if (!use_ltran()) {
 #if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0)
         dpdk_kni_release();
-- 
2.27.0

