From 255c202107357875c1a4c4786d037f15dbdeb602 Mon Sep 17 00:00:00 2001 From: Yilong Li Date: Tue, 2 Jul 2019 14:45:03 -0700 Subject: [PATCH] Fixed segfault in Nexus::Nexus when there are offline CPUs --- .gitignore | 2 ++ src/nexus_impl/nexus.cc | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 895a6eba..70daee0f 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ CMakeScripts Makefile Testing CTestTestfile.cmake +cmake-build* # gdb .gdb_history @@ -66,3 +67,4 @@ gdb_history *.swp src/config.h .ycm_extra_conf.py +.idea diff --git a/src/nexus_impl/nexus.cc b/src/nexus_impl/nexus.cc index 94b551a1..1e14424a 100644 --- a/src/nexus_impl/nexus.cc +++ b/src/nexus_impl/nexus.cc @@ -58,11 +58,11 @@ Nexus::Nexus(std::string local_uri, size_t numa_node, size_t num_bg_threads) sm_thread_ctx.reg_hooks_lock = ®_hooks_lock; // Bind the session management thread to the last lcore on numa_node - size_t sm_thread_lcore_index = num_lcores_per_numa_node() - 1; + auto lcores = get_lcores_for_numa_node(numa_node); ERPC_INFO("eRPC Nexus: Launching session management thread on core %zu.\n", - get_lcores_for_numa_node(numa_node).at(sm_thread_lcore_index)); + lcores.back()); sm_thread = std::thread(sm_thread_func, sm_thread_ctx); - bind_to_core(sm_thread, numa_node, sm_thread_lcore_index); + bind_to_core(sm_thread, numa_node, lcores.size() - 1); ERPC_INFO("eRPC Nexus: Created with management UDP port %u, hostname %s.\n", sm_udp_port, hostname.c_str());