From a5fe735c50253a1a0af37c131317ae454c5a6d0f Mon Sep 17 00:00:00 2001 From: Georgiy Lebedev <g.lebedev@tarantool.org> Date: Tue, 17 Jan 2023 14:19:56 +0300 Subject: [PATCH] console: make prompt bookkeeping thread-safe Prompt bookkeeping introduced in 66ca6252 is not thread-safe, whilst the logging environment is multithreaded: leave this feature only in main (transaction) thread. Closes #8124 NO_CHANGELOG=<gh-7169 was not release yet> NO_DOC=bugfix NO_TEST=<hard to make Tarantool flood log from multiple threads using current test harness> --- src/box/lua/console.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/box/lua/console.c b/src/box/lua/console.c index ee94af696a..6bc9067b0b 100644 --- a/src/box/lua/console.c +++ b/src/box/lua/console.c @@ -274,6 +274,9 @@ console_sigint_handler(ev_loop *loop, struct ev_signal *w, int revents) /* * The idea is borrowed from * https://metacpan.org/dist/AnyEvent-ReadLine-Gnu/source/Gnu.pm + * + * Since this feature is not thread-safe, it will work only when logging occurs + * from main (transaction) thread. */ static char *saved_prompt = NULL; @@ -311,7 +314,7 @@ console_can_hide_show_prompt(void) static void console_hide_prompt(void) { - if (!console_can_hide_show_prompt()) + if (!console_can_hide_show_prompt() || !cord_is_main()) return; if (rl_prompt == NULL) { @@ -343,7 +346,7 @@ console_hide_prompt(void) static void console_show_prompt(void) { - if (!console_can_hide_show_prompt()) + if (!console_can_hide_show_prompt() || !cord_is_main()) return; rl_set_prompt(saved_prompt); -- GitLab