From 53969ac0be85346d2abd776c66d4ff244c9f5da7 Mon Sep 17 00:00:00 2001 From: wuchangsheng Date: Mon, 14 Mar 2022 22:41:57 +0800 Subject: [PATCH 28/34] fix lstack show latency --- src/lstack/core/lstack_init.c | 6 ++++++ src/lstack/core/lstack_stack_stat.c | 5 +++++ src/ltran/ltran_dfx.c | 2 -- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c index df60c4f..17195c8 100644 --- a/src/lstack/core/lstack_init.c +++ b/src/lstack/core/lstack_init.c @@ -190,6 +190,12 @@ __attribute__((constructor)) void gazelle_network_init(void) LSTACK_EXIT(1, "pthread_getaffinity_np failed\n"); } + /* to prevent crash , just ignore SIGPIPE when socket is closed */ + if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { + LSTACK_PRE_LOG(LSTACK_ERR, "signal error, errno:%d.", errno); + LSTACK_EXIT(1, "signal SIGPIPE SIG_IGN\n"); + } + /* * Phase 6: Init control plane and dpdk init */ pthread_t tid; diff --git a/src/lstack/core/lstack_stack_stat.c b/src/lstack/core/lstack_stack_stat.c index 9a8fd08..1813906 100644 --- a/src/lstack/core/lstack_stack_stat.c +++ b/src/lstack/core/lstack_stack_stat.c @@ -190,6 +190,11 @@ int32_t handle_stack_cmd(int32_t fd, enum GAZELLE_STAT_MODE stat_mode) struct protocol_stack *stack = stack_group->stacks[i]; get_stack_dfx_data(&dfx, stack, stat_mode); + if (!use_ltran() && + (stat_mode == GAZELLE_STAT_LTRAN_START_LATENCY || stat_mode == GAZELLE_STAT_LTRAN_STOP_LATENCY)) { + continue; + } + dfx.tid = stack->tid; if (i == stack_group->stack_num - 1) { dfx.eof = 1; diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c index a575c33..3baa017 100644 --- a/src/ltran/ltran_dfx.c +++ b/src/ltran/ltran_dfx.c @@ -1231,8 +1231,6 @@ int32_t main(int32_t argc, char *argv[]) if (!g_use_ltran) { g_gazelle_dfx_tbl[GAZELLE_STAT_LSTACK_SHOW].recv_size = sizeof(struct gazelle_stack_dfx_data); - g_gazelle_dfx_tbl[GAZELLE_STAT_LTRAN_START_LATENCY].recv_size =sizeof(struct gazelle_stack_dfx_data); - g_gazelle_dfx_tbl[GAZELLE_STAT_LTRAN_STOP_LATENCY].recv_size =sizeof(struct gazelle_stack_dfx_data); ret = check_cmd_support(req_msg, req_msg_num); if (ret < 0) { return -1; -- 1.8.3.1