Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko <sergepetrenko@tarantool.org>
To: vdavydov.dev@gmail.com
Cc: tarantool-patches@freelists.org,
	Serge Petrenko <sergepetrenko@tarantool.org>
Subject: [PATCH] lua: fix tarantool -e "os.exit()" hang.
Date: Wed,  6 Feb 2019 14:36:18 +0300	[thread overview]
Message-ID: <20190206113618.47290-1-sergepetrenko@tarantool.org> (raw)

After the patch which made os.exit() execute on_shutdown triggers
(see commit 6dc4c8d7b5b40d66fe0451ef4d1f4bdf4d2cf60e) we relied
on on_shutdown triggers to break the ev_loop and exit tarantool.
Hovewer, there is an auxiliary event loop which is run in
tarantool_lua_run_script() to reschedule the fiber executing chunks
of code passed by -e option and executing interactive mode.
This event loop is started only to execute interactive mode, and
doesn't exist during execution of -e chunks. Make sure we don't start
it if os.exit() was already executed in one of the chunks.

Closes #3966
---
https://github.com/tarantool/tarantool/issues/3966
https://github.com/tarantool/tarantool/tree/sp/gh-3966-os-exit-hang

 src/lua/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/lua/init.c b/src/lua/init.c
index ca4b47f3a..d18c8af94 100644
--- a/src/lua/init.c
+++ b/src/lua/init.c
@@ -664,7 +664,8 @@ tarantool_lua_run_script(char *path, bool interactive,
 	 * Run an auxiliary event loop to re-schedule run_script fiber.
 	 * When this fiber finishes, it will call ev_break to stop the loop.
 	 */
-	ev_run(loop(), 0);
+	if (start_loop)
+		ev_run(loop(), 0);
 	/* The fiber running the startup script has ended. */
 	script_fiber = NULL;
 }
-- 
2.17.2 (Apple Git-113)

             reply	other threads:[~2019-02-06 11:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-06 11:36 Serge Petrenko [this message]
2019-02-06 12:26 ` Vladimir Davydov
2019-02-06 13:32   ` Serge Petrenko
2019-02-06 14:06     ` 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=20190206113618.47290-1-sergepetrenko@tarantool.org \
    --to=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [PATCH] lua: fix tarantool -e "os.exit()" hang.' \
    /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