From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp21.mail.ru (smtp21.mail.ru [94.100.179.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 55C40469710 for ; Sun, 7 Jun 2020 19:58:55 +0300 (MSK) Date: Sun, 7 Jun 2020 19:58:41 +0300 From: Alexander Turenko Message-ID: <20200607165841.mqnfpeezdzxfod7r@tkn_work_nb> References: <353b8524edba38a68642a10d5b6bd6b033477e33.1591028838.git.alexander.turenko@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH 3/3] lua: expose temporary Lua state for iproto calls List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.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.