[Tarantool-patches] [PATCH 2/4] box/func: update module cache in one pass
Cyrill Gorcunov
gorcunov at gmail.com
Wed Feb 17 23:15:19 MSK 2021
When module get reloaded we can update the
cache entry directly instead of delete+add
pair.
Part-of #4642
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
src/box/func.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/box/func.c b/src/box/func.c
index 0d552652d..5757f7c25 100644
--- a/src/box/func.c
+++ b/src/box/func.c
@@ -159,6 +159,21 @@ module_cache_put(struct module *module)
return 0;
}
+/**
+ * Update the module cache.
+ */
+static void
+module_cache_update(struct module *module)
+{
+ const char *package = module->cmod->package;
+ size_t package_len = module->cmod->package_len;
+ mh_int_t i = mh_strnptr_find_inp(modules, package, package_len);
+ if (i == mh_end(modules))
+ panic("failed to update module cache");
+ mh_strnptr_node(modules, i)->str = package;
+ mh_strnptr_node(modules, i)->val = module;
+}
+
/**
* Delete a module from the module cache
*/
@@ -281,9 +296,7 @@ module_reload(const char *package, const char *package_end)
func->module = new_module;
rlist_move(&new_module->funcs, &func->item);
}
- module_cache_del(package, package_end);
- if (module_cache_put(new_module) != 0)
- goto restore;
+ module_cache_update(new_module);
module_gc(old_module);
return 0;
restore:
--
2.29.2
More information about the Tarantool-patches
mailing list