[Tarantool-patches] [PATCH 1/1] fio: close unused descriptors automatically
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Mon Feb 10 22:36:55 MSK 2020
Hi! Thanks for your review!
On 09/02/2020 19:34, Georgy Kirichenko wrote:
> Hi, thanks for the patch.
>
> Unfortunately your patch is not correct because fiber.create
> yields (which could be fixed by using fiber.new) and raises an error what is not
> allowed inside gc callbacks.
Good catch!
================================================================================
-- FFI GC can't yield. Internal.close() yields.
-- Collect the garbage later, in a separate fiber.
- fiber.create(internal.close, fh)
+ fiber.new(internal.close, fh)
end)
}, fio_mt)
================================================================================
> From my point of view the possible approach is a dedicated fiber with
> a list of pending callbacks.
Yes, I was thinking about this as well, but thought it would be an overkill
just for fio. Since you also propose this solution, I suggest to do it
separately, and for other modules too. We could introduce a new module
'background', or 'gc', or 'worker', or 'pool' which would provide API like
'execute(func, arg)'. And it would call it in a special global fiber.
Example:
pool = require('pool')
pool.execute(internal.close, fd)
So basically we could reinvent fiber pool for Lua.
This can be used for fio and SWIM objects GC, because SWIM currently
also creates a new fiber in its GC callback.
Also this could be implemented as a submodule of fiber module. For instance,
fiber.pool.execute().
More information about the Tarantool-patches
mailing list