[PATCH] box/lua/console: Fix hang in case of cancelling console fiber
Cyrill Gorcunov
gorcunov at gmail.com
Tue May 28 23:37:42 MSK 2019
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
More information about the Tarantool-patches
mailing list