Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@freelists.org, tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] app: exit gracefully when a main script throws an error
Date: Fri, 25 Oct 2019 02:04:46 +0300	[thread overview]
Message-ID: <20191024230446.qzsmvikw5f4y3rvb@tkn_work_nb> (raw)
In-Reply-To: <f49ce585-eee9-d3bf-e1d8-41d0a68e0e14@tarantool.org>

> >> @@ -678,6 +686,12 @@ tarantool_lua_run_script(char *path, bool interactive,
> >>  		ev_run(loop(), 0);
> >>  	/* The fiber running the startup script has ended. */
> >>  	script_fiber = NULL;
> >> +	/*
> >> +	 * Result can't be obtained via fiber_join - script fiber
> >> +	 * never dies if os.exit() was called. This is why diag
> >> +	 * is checked explicitly.
> >> +	 */
> >> +	return diag_is_empty(diag_get()) ? 0 : -1;
> > 
> > This is the only part I'm a bit tentative: can the diagnostic area be
> > populated by a user somehow? I tried to do--
> > 
> >  | fio.open('non_existent', {'O_RDONLY'})
> >  | os.exit()
> > 
> > --in the main script and it seems that it uses some other diagnostic
> > area, because the fio error was not reported as the main script fail.
> 
> Should it have been reported?

No, current behaviour looks right for me.

> Talking of why it is not now - well, yes, it uses another diagnostics
> area. tarantool_lua_run_script() starts a special fiber to run a
> script or a console. And the error is forwarded to the main fiber
> only when the script fiber does it voluntary, in the end of
> run_script_f().
> 
> In case of os.exit() the script fiber never finishes, and therefore
> never moves its diag to the main fiber. Os.exit() breaks event loop
> and freezes the current fiber. It makes ev_run() return in
> tarantool_lua_run_script(). After that we see that the diag is empty,
> because the script fiber never got to the point of filling it.

Now I understood the logic, thanks!

      reply	other threads:[~2019-10-24 23:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10 22:00 [tarantool-patches] " Vladislav Shpilevoy
2019-10-24  0:21 ` [Tarantool-patches] " Alexander Turenko
2019-10-24 19:53   ` [Tarantool-patches] [tarantool-patches] " Vladislav Shpilevoy
2019-10-24 23:04     ` Alexander Turenko [this message]

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=20191024230446.qzsmvikw5f4y3rvb@tkn_work_nb \
    --to=alexander.turenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] app: exit gracefully when a main script throws an error' \
    /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