Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tml <tarantool-patches@dev.tarantool.org>
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [Tarantool-patches] [PATCH 2/4] box/func: update module cache in one pass
Date: Wed, 17 Feb 2021 23:15:19 +0300
Message-ID: <20210217201521.436951-3-gorcunov@gmail.com> (raw)
In-Reply-To: <20210217201521.436951-1-gorcunov@gmail.com>

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@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


  parent reply	other threads:[~2021-02-17 20:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17 12:39 [Tarantool-patches] [PATCH v18 0/2] box: implement cmod Lua module Cyrill Gorcunov via Tarantool-patches
2021-02-17 12:39 ` [Tarantool-patches] [PATCH v18 1/2] box/cmod: " Cyrill Gorcunov via Tarantool-patches
2021-02-17 12:39 ` [Tarantool-patches] [PATCH v18 2/2] test: box/cfunc -- add cmod test Cyrill Gorcunov via Tarantool-patches
2021-02-17 20:15 ` [Tarantool-patches] [PATCH 0/4] cmod: refactor box/func Cyrill Gorcunov via Tarantool-patches
2021-02-17 20:15   ` [Tarantool-patches] [PATCH 1/4] box/func: drop redundant module argument Cyrill Gorcunov via Tarantool-patches
2021-02-17 20:15   ` Cyrill Gorcunov via Tarantool-patches [this message]
2021-02-17 20:15   ` [Tarantool-patches] [PATCH 3/4] cmod: export cmod_call helper Cyrill Gorcunov via Tarantool-patches
2021-02-17 20:15   ` [Tarantool-patches] [PATCH 4/4] box/func: simplify func_c_call Cyrill Gorcunov via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210217201521.436951-3-gorcunov@gmail.com \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=v.shpilevoy@tarantool.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git