From d18ec6e392627b64355808a0b6a0bcd9ff66c2c8 Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Mon, 24 Jan 2022 16:10:34 +0000 Subject: [PATCH] spdk_top: make pollers tab refresh with pollers pop-up active Changes refreshing of pollers tab to be done from within poller pop-up display function. As mentioned before, NCURSES does not behave predictably, when different parts of screen are refreshed from within multiple functions at a time, so the "control" of refreshing has to be passed to one function. Adds refreshing of pollers pop-up. Signed-off-by: Krzysztof Karas Change-Id: I37dcedc495c314462b252774d97410158e1b895d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7393 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- app/spdk_top/spdk_top.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index f65480d10..2a6bd706f 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -2634,11 +2634,10 @@ draw_poller_win_content(WINDOW *poller_win, struct rpc_poller_info *poller_info) } wnoutrefresh(poller_win); - refresh(); } static void -show_poller(uint8_t current_page) +show_poller(uint8_t current_page, uint8_t active_tab) { PANEL *poller_panel; WINDOW *poller_win; @@ -2646,6 +2645,12 @@ show_poller(uint8_t current_page) struct rpc_poller_info *poller; bool stop_loop = false; int c; + long int time_last, time_dif; + struct timespec time_now; + + clock_gettime(CLOCK_MONOTONIC, &time_now); + time_last = time_now.tv_sec; + pthread_mutex_lock(&g_thread_lock); @@ -2663,10 +2668,11 @@ show_poller(uint8_t current_page) update_panels(); doupdate(); draw_poller_win_content(poller_win, poller); + refresh(); pthread_mutex_unlock(&g_thread_lock); while (!stop_loop) { - c = wgetch(poller_win); + c = getch(); switch (c) { case 27: /* ESC */ stop_loop = true; @@ -2674,6 +2680,18 @@ show_poller(uint8_t current_page) default: break; } + + clock_gettime(CLOCK_MONOTONIC, &time_now); + time_dif = time_now.tv_sec - time_last; + + if (time_dif >= g_sleep_time) { + time_last = time_now.tv_sec; + pthread_mutex_lock(&g_thread_lock); + refresh_tab(active_tab, current_page); + draw_poller_win_content(poller_win, poller); + refresh(); + pthread_mutex_unlock(&g_thread_lock); + } } del_panel(poller_panel); @@ -2937,7 +2955,7 @@ show_stats(pthread_t *data_thread) } else if (active_tab == CORES_TAB) { show_core(current_page, active_tab); } else if (active_tab == POLLERS_TAB) { - show_poller(current_page); + show_poller(current_page, active_tab); } break; case 'h':