From: Cyrill Gorcunov <gorcunov@gmail.com>
To: tarantool <tarantool-patches@freelists.org>
Cc: Alexander Turenko <alexander.turenko@tarantool.org>,
Kirill Yukhin <kyukhin@tarantool.org>,
Konstantin Osipov <kostja@tarantool.org>,
Vladimir Davydov <vdavydov.dev@gmail.com>
Subject: [PATCH] box/lua/console: Fix hang in case of cancelling console fiber
Date: Tue, 28 May 2019 23:37:42 +0300 [thread overview]
Message-ID: <20190528203742.GR11013@uranus> (raw)
Since commit f42596a2266479337b6d101befaae6fbf0943f37 we've started
to test if a fiber is cancelled in coio_wait. This may hang interactive
console with simple fiber.kill(fiber.self()) call.
Sane users don't do such tricks and this affects interactive console
mode only but still to be on a safe side lets exit if someone occasionally
killed the console fiber.
Notes:
- such exit may ruine terminals settings and one need
to reset it after;
- the issue happens on interactive console only
so I didn't find a way for automatic test and
tested manually.
---
src/box/lua/console.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/box/lua/console.c b/src/box/lua/console.c
index 085aedfaf..cefe5d863 100644
--- a/src/box/lua/console.c
+++ b/src/box/lua/console.c
@@ -229,8 +229,15 @@ lbox_console_readline(struct lua_State *L)
top = lua_gettop(L);
while (top == lua_gettop(L)) {
while (coio_wait(STDIN_FILENO, COIO_READ,
- TIMEOUT_INFINITY) == 0);
-
+ TIMEOUT_INFINITY) == 0) {
+ /*
+ * Make sure the user of interactive
+ * console has not hanged us, otherwise
+ * we might spin here forever eating
+ * the whole cpu time.
+ */
+ luaL_testcancel(L);
+ }
rl_callback_read_char();
}
--
2.20.1
next reply other threads:[~2019-05-28 20:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 20:37 Cyrill Gorcunov [this message]
2019-05-29 16:12 ` Vladimir Davydov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190528203742.GR11013@uranus \
--to=gorcunov@gmail.com \
--cc=alexander.turenko@tarantool.org \
--cc=kostja@tarantool.org \
--cc=kyukhin@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=vdavydov.dev@gmail.com \
--subject='Re: [PATCH] box/lua/console: Fix hang in case of cancelling console fiber' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox