[Tarantool-patches] [PATCH v15 07/11] module_cache: use references as a main usage counter
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sun Feb 7 20:20:34 MSK 2021
Thanks for the patch!
See 2 comments below.
> +
> +/**
> + * Decrease module reference and delete it if last one.
> + */
> +static void
> +module_unref(struct module *module)
> +{
> + assert(module->refs > 0);
> + if (module->refs-- == 1) {
> + if (!module_is_orphan(module)) {
> + size_t len = strlen(module->package);
> + module_cache_del(module->package,
> + &module->package[len]);
1. You can also compare pointer in the hash. If it matches -
delete it. Then you wouldn't need the orphan concept at all.
> + }
> + module_delete(module);
> + }
> +}
> @@ -511,10 +541,15 @@ module_reload(const char *package, const char *package_end)
> panic("module: can't update module cache (%s)", package);
> }
>
> - module_gc(old);
> + module_set_orphan(old);
> + module_unref(old);
> +
> + /* From explicit load above */
> + module_unref(new);
2. Where is the explicit ref?
More information about the Tarantool-patches
mailing list