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@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 3/3] lua: expose temporary Lua state for iproto calls
Date: Sun, 7 Jun 2020 19:58:41 +0300	[thread overview]
Message-ID: <20200607165841.mqnfpeezdzxfod7r@tkn_work_nb> (raw)
In-Reply-To: <dae4442d-9daa-8e0d-101f-07899336794a@tarantool.org>

> > +	/*
> > +	 * A code that need a temporary fiber-local Lua state may
> > +	 * save some time and resources for creating a new state
> > +	 * and use this one.
> > +	 */
> > +	bool has_lua_stack = fiber()->storage.lua.stack != NULL;
> > +	if (! has_lua_stack)
> > +		fiber()->storage.lua.stack = L;
> 
> 1. According to recent code style changes, we should omit single
> whitespace after unary operators.

Fixed.

> > +	/*
> > +	 * Since this field is optional we're not obligated to
> > +	 * keep it until the Lua state will be unreferenced in
> > +	 * port_lua_destroy().
> > +	 *
> > +	 * There is no much sense to keep it beyond the Lua call,
> > +	 * so let's zap now.
> > +	 *
> > +	 * But: keep the stack if it was present before the call,
> > +	 * because it would be counter-intuitive if the existing
> > +	 * state pointer would be zapped after this function call.
> 
> 2. It is not just counter-intuitive. It would break Lua-born fibers,
> since they would suddenly loose their stack.

Nope, it'll work.

Once we put the stack into a Lua-born fiber, this field may be safely
zapped. (I looked into this, because I want to create a test case that
would verify whether we keep the existing state here, but failed to find
such scenario.)

> >  		/**
> > -		 * Lua stack and the optional
> > -		 * fiber.storage Lua reference.
> > +		 * Optional Lua state (may be NULL). Useful as a
> > +		 * temporary Lua state to save time and resources
> > +		 * on creating it. Should not be used in other
> > +		 * fibers.
> > +		 *
> > +		 * Optional fiber.storage Lua reference.
> 
> 3. You change the comment anyway, so it would be better to make it
> right and put the member-related comments just above the members.
> One comment for the stack, and separate comment for the ref.

Fixed.

  reply	other threads:[~2020-06-07 16:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-01 18:10 [Tarantool-patches] [PATCH 0/3] Merger's NULL defererence Alexander Turenko
2020-06-01 18:10 ` [Tarantool-patches] [PATCH 1/3] merger: drop luaL prefix where contract allows it Alexander Turenko
2020-06-02 22:47   ` Vladislav Shpilevoy
2020-06-07 16:57     ` Alexander Turenko
2020-06-11 16:17       ` Vladislav Shpilevoy
2020-06-16 11:59       ` Igor Munkin
2020-06-17 17:53         ` Alexander Turenko
2020-06-01 18:10 ` [Tarantool-patches] [PATCH 2/3] merger: fix NULL dereference when called via iproto Alexander Turenko
2020-06-02 22:48   ` Vladislav Shpilevoy
2020-06-07 16:58     ` Alexander Turenko
2020-06-11 16:18       ` Vladislav Shpilevoy
2020-06-17 17:53         ` Alexander Turenko
2020-06-18 22:47           ` Vladislav Shpilevoy
2020-06-01 18:10 ` [Tarantool-patches] [PATCH 3/3] lua: expose temporary Lua state for iproto calls Alexander Turenko
2020-06-02 22:48   ` Vladislav Shpilevoy
2020-06-07 16:58     ` Alexander Turenko [this message]
2020-06-02 22:47 ` [Tarantool-patches] [PATCH 0/3] Merger's NULL defererence Vladislav Shpilevoy
2020-06-07 17:17   ` Alexander Turenko
2020-06-07 16:58 ` [Tarantool-patches] [PATCH 2.5/3] merger: clean fiber-local Lua stack after next() Alexander Turenko
2020-06-11 16:20   ` Vladislav Shpilevoy
2020-06-17 17:53     ` Alexander Turenko
2020-06-18 22:48       ` Vladislav Shpilevoy
2020-06-19  7:41         ` Alexander Turenko
2020-06-17 17:54 ` [Tarantool-patches] [PATCH 0/3] Merger's NULL defererence Alexander Turenko

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=20200607165841.mqnfpeezdzxfod7r@tkn_work_nb \
    --to=alexander.turenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 3/3] lua: expose temporary Lua state for iproto calls' \
    /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