From 5ad5406de3e7d554cb774e9b22c3f5cfb33efc3e Mon Sep 17 00:00:00 2001
From: Li Ma
Date: Wed, 11 Sep 2024 11:14:52 +0800
Subject: [PATCH] SWDEV-445415 - Pthread detach instead of pthread join
Detcah the thread which handle shutdown signals instead of joining
thread can avoid the segfault issue on specific ASIC.
Signed-off-by: Li Ma
Change-Id: I74ac53c027ac370605caaa87115c83fd8027526a
[ROCm/rdc commit: ca569346a33b8d57243161e7b50ed74b3150ae92]
---
projects/rdc/server/src/rdc_server_main.cc | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/projects/rdc/server/src/rdc_server_main.cc b/projects/rdc/server/src/rdc_server_main.cc
index e0b76f193e..e72fb47758 100644
--- a/projects/rdc/server/src/rdc_server_main.cc
+++ b/projects/rdc/server/src/rdc_server_main.cc
@@ -663,21 +663,19 @@ int main(int argc, char** argv) {
return 1;
}
+ // Detach the thread, sys will recycle the resource
+ thr_ret = pthread_detach(sig_listen_thread);
+ // Don't fail if detach is not successful
+ if (thr_ret !=0) {
+ std::cerr << "Failed to detach ProcessSignalLoop. pthread_detach() returned " << thr_ret;
+ }
+
// TODO(cfreehil): Eventually, set these by reading a config file
rdc_server.set_start_rdc_admin_service(true);
rdc_server.set_start_api_service(true);
rdc_server.Run();
- // join the thread to prevent the program terminated
- void* ret = nullptr;
- thr_ret = pthread_join(sig_listen_thread, &ret);
-
- // don't fail if it doesn't succeed
- if (thr_ret != 0) {
- std::cerr << "Failed to terminate ProcessSignalLoop. pthread_join() returned " << thr_ret;
- }
-
if (sShutDownServer) {
std::cout << "RDC server successfully shut down." << std::endl;
return 0;