Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH] box/lua/console: Fix hang in case of cancelling console fiber
@ 2019-05-28 20:37 Cyrill Gorcunov
  2019-05-29 16:12 ` Vladimir Davydov
  0 siblings, 1 reply; 2+ messages in thread
From: Cyrill Gorcunov @ 2019-05-28 20:37 UTC (permalink / raw)
  To: tarantool
  Cc: Alexander Turenko, Kirill Yukhin, Konstantin Osipov, Vladimir Davydov

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] box/lua/console: Fix hang in case of cancelling console fiber
  2019-05-28 20:37 [PATCH] box/lua/console: Fix hang in case of cancelling console fiber Cyrill Gorcunov
@ 2019-05-29 16:12 ` Vladimir Davydov
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Davydov @ 2019-05-29 16:12 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: tarantool, Alexander Turenko, Kirill Yukhin, Konstantin Osipov

Pushed to master, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-29 16:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-28 20:37 [PATCH] box/lua/console: Fix hang in case of cancelling console fiber Cyrill Gorcunov
2019-05-29 16:12 ` Vladimir Davydov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox