Skip to content

Commit

Permalink
SWDEV-445415 - Pthread detach instead of pthread join
Browse files Browse the repository at this point in the history
Detcah the thread which handle shutdown signals instead of joining
thread can avoid the segfault issue on specific ASIC.

Signed-off-by: Li Ma <[email protected]>
Change-Id: I74ac53c027ac370605caaa87115c83fd8027526a
  • Loading branch information
Li Ma authored and Maisam Arif committed Sep 20, 2024
1 parent a0f7290 commit 5bd283d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions server/src/rdc_server_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -653,21 +653,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;
Expand Down

0 comments on commit 5bd283d

Please sign in to comment.