From: Leonid Vasiliev <lvasiliev@tarantool.org> To: Artem Starshov <artemreyt@tarantool.org>, Alexander Turenko <alexander.turenko@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH 1/2] src/lua: fix running init lua script Date: Thu, 10 Dec 2020 20:38:41 +0300 [thread overview] Message-ID: <b17daf6f-cdf8-a966-779a-5018fa5105d7@tarantool.org> (raw) In-Reply-To: <cd7ede5853dc71d61a80c4e9d2ed634958734df9.1607541187.git.artemreyt@tarantool.org> Hi! Thank you for the patch. LGTM On 09.12.2020 22:28, Artem Starshov wrote: > When tarantool launched with -e flag > and in script after there is an error, > programm hangs. This happens because > shed fiber launches separate fiber for > init user script and starts auxiliary event > loop. It's supposed that fiber will stop this > loop, but in case of error in script, fiber tries > to stop a loop when the last one isn't started yet. Nice stairs) > > Added a flag, which will watch is loop started and > when fiber tries to call `ev_break()` we can be sure > that loop is runnig already. > > Part of #4983 Closes. > --- > src/lua/init.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/src/lua/init.c b/src/lua/init.c > index a0b2fc775..92bdb82c0 100644 > --- a/src/lua/init.c > +++ b/src/lua/init.c > @@ -569,6 +569,7 @@ run_script_f(va_list ap) > * never really dead. It never returns from its function. > */ > struct diag *diag = va_arg(ap, struct diag *); > + bool aux_loop_is_run = false; > > /* > * Load libraries and execute chunks passed by -l and -e > @@ -611,6 +612,7 @@ run_script_f(va_list ap) > * loop and re-schedule this fiber. > */ > fiber_sleep(0.0); > + aux_loop_is_run = true; > > if (path && strcmp(path, "-") != 0 && access(path, F_OK) == 0) { > /* Execute script. */ > @@ -650,6 +652,13 @@ run_script_f(va_list ap) > * return control back to tarantool_lua_run_script. > */ > end: > + /* > + * Auxiliary loop in tarantool_lua_run_script > + * should start (ev_run()) before this fiber > + * invokes ev_break(). > + */ > + if (!aux_loop_is_run) > + fiber_sleep(0.0); > ev_break(loop(), EVBREAK_ALL); > return 0; > >
next prev parent reply other threads:[~2020-12-10 17:39 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-09 19:28 [Tarantool-patches] [PATCH 0/2] tarantool -e 'assert(false)' hangs Artem Starshov 2020-12-09 19:28 ` [Tarantool-patches] [PATCH 1/2] src/lua: fix running init lua script Artem Starshov 2020-12-10 17:38 ` Leonid Vasiliev [this message] 2020-12-10 17:42 ` Leonid Vasiliev 2020-12-09 19:28 ` [Tarantool-patches] [PATCH 2/2] test: add test for tarantool -e assert(false) Artem Starshov 2020-12-10 18:11 ` Leonid Vasiliev 2020-12-14 14:11 ` Artem 2020-12-10 17:33 ` [Tarantool-patches] [PATCH 0/2] tarantool -e 'assert(false)' hangs Leonid Vasiliev
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=b17daf6f-cdf8-a966-779a-5018fa5105d7@tarantool.org \ --to=lvasiliev@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=artemreyt@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 1/2] src/lua: fix running init lua script' \ /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