[Tarantool-patches] [PATCH v5 5/6] box/cbox: implement cbox Lua module

Cyrill Gorcunov gorcunov at gmail.com
Fri Oct 9 09:57:55 MSK 2020


On Fri, Oct 09, 2020 at 12:35:09AM +0200, Vladislav Shpilevoy wrote:
> > +
> > +#include "box/error.h"
> > +#include "box/func.h"
> 
> 1. Why do you still depend on box/func.h? Func.h is
> about stored functions with credentials and stuff. In the
> previous review I proposed to move needed parts to a new
> system: module_sym of whatever it is called. So it would
> be module_sym.h and module_sym.c. And it would not depend
> on schema at all. Currently func.h brings schema dependency
> into cbox.

Well, I remember your proposal. The reason is indeed to include
module_sym structure which sits in func.h. I thought we could
make this separation later together with fix of lazy address
loading. But on the other hands let me try to implement it
today.

> Maybe a good name for the new system would be module_cache.h
> and module_cache.c. Like we have with coll_id_cache.h/.c.
> (The structs can remain module_sym.)

Sounds reasonable.

> > +
> > +	int coro_ref = luaL_ref(tarantool_L, LUA_REGISTRYINDEX);
> > +	lua_xmove(L, args_L, lua_gettop(L) - 1);
> 
> 2. Why didn't you use lua_remove() to get rid of the unnecessary
> parts of the stack?

Which one you think is redundant? The object itself? If so then
it sits as a bottom element of the stack and removing it would
simply make code slower.

Vlad this "prepare environment for calling" part of code is very
sensitive to the arguments, I tried a various combinations in
attempts to get rid of lua thread and none of them work. So I
left it as is and put a FIXME, because it requires more serious
rework.

Or I misundertood you, and you meant something different?

> > +
> > +	lua_pushstring(L, "__call");
> > +	lua_pushcfunction(L, lcbox_func_call);
> > +	lua_settable(L, -3);
> > +
> > +	lua_setmetatable(L, -2);
> 
> 3. What happens when the function object is deleted by Lua GC?
> It seems the user can't get the function again without dropping
> it.

And that is a good question. I must confess I missed Lua GC aspect
here. Thanks a huge! I'll rework!


More information about the Tarantool-patches mailing list