Skip to content
Snippets Groups Projects
Commit a5fe735c authored by Georgiy Lebedev's avatar Georgiy Lebedev Committed by Vladimir Davydov
Browse files

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>
parent c9986d93
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment