From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tml <tarantool-patches@dev.tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v21 5/6] box: implement box.lib module Date: Mon, 12 Apr 2021 01:38:00 +0300 [thread overview] Message-ID: <YHN6SEB4oD8zb9iq@grain> (raw) In-Reply-To: <0868de76-3941-ed34-3d7e-2f7328e30934@tarantool.org> On Sun, Apr 11, 2021 at 05:38:51PM +0200, Vladislav Shpilevoy wrote: > Thanks for the patch! > > Please, try to respond to my comments in the original email, > explicitly. When and how you fixed them, or why did not. Not > with promises like "will do", "ok", and so on, they don't help > much. > > Otherwise I see you tend to miss some of the comments. Also I > don't remember all of my comments, so when you don't respond to > them, I need to go to my old email, and match the comments > with the places you was supposed to fix, and it takes time. > > See how Sergey and Mergen send their patches for examples. > > https://github.com/tarantool/tarantool/wiki/Code-review-procedure#during-the-review > > See 4 comments below. I fixed the change log. And here is a diff on top, please take a look. --- Subject: [PATCH] box.lib fix Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> --- src/box/lua/lib.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/box/lua/lib.c b/src/box/lua/lib.c index 5fb616d04..2181b9030 100644 --- a/src/box/lua/lib.c +++ b/src/box/lua/lib.c @@ -97,12 +97,22 @@ cache_put(struct box_module_func *cf) .hash = mh_strn_hash(cf->key, cf->len), .val = cf, }; - mh_int_t e = mh_strnptr_put(func_hash, &nd, NULL, NULL); + + struct mh_strnptr_node_t prev; + struct mh_strnptr_node_t *prev_ptr = &prev; + + mh_int_t e = mh_strnptr_put(func_hash, &nd, &prev_ptr, NULL); if (e == mh_end(func_hash)) { diag_set(OutOfMemory, sizeof(nd), "malloc", "box.lib: hash node"); return -1; } + + /* + * Just to make sure we haven't replaced something, + * the entries must be explicitly deleted. + */ + assert(prev_ptr == NULL); return 0; } @@ -383,7 +393,15 @@ lbox_module_load_func(struct lua_State *L) size_t sym_len; const char *sym = lua_tolstring(L, 2, &sym_len); - const size_t max_sym_len = 512; + + /* + * C standard requires at least 63 significant + * initial characters, though it advises to not + * impose limits. Lets make the max identifier + * big enough to keep longest id, which is hardly + * be bigger than 256 symbols. + */ + const size_t max_sym_len = 256; if (sym_len < 1) { diag_set(IllegalParams, fmt_noname, method); @@ -400,13 +418,12 @@ lbox_module_load_func(struct lua_State *L) * per module. The symbol (function name) is the * last part of the hash key. * - * The key's buffer should be big enough to keep - * the longest package path plus symbol name and - * the pointer. + * Make sure there is enough space for key, + * path and formatting. */ - char key[PATH_MAX + 2 * max_sym_len]; + char key[PATH_MAX + max_sym_len + 32]; snprintf(key, sizeof(key), "%p.%s.%s", - (void *)m, m->package, sym); + m, m->package, sym); size_t len = strlen(key); struct box_module_func *cf = cache_find(key, len); -- 2.30.2
next prev parent reply other threads:[~2021-04-11 22:38 UTC|newest] Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-08 16:41 [Tarantool-patches] [PATCH v21 0/6] box: implement box.lib Lua module Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 1/6] box/func: fix modules functions restore Cyrill Gorcunov via Tarantool-patches 2021-04-09 23:31 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-10 15:02 ` Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 2/6] box/func: module_reload -- drop redundant argument Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 3/6] box/module_cache: introduce modules subsystem Cyrill Gorcunov via Tarantool-patches 2021-04-09 23:54 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-10 14:59 ` Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 4/6] box/schema.func: switch to new module api Cyrill Gorcunov via Tarantool-patches 2021-04-09 23:55 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-10 15:00 ` Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 5/6] box: implement box.lib module Cyrill Gorcunov via Tarantool-patches 2021-04-11 15:38 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-11 22:38 ` Cyrill Gorcunov via Tarantool-patches [this message] 2021-04-12 22:08 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-12 22:34 ` Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 6/6] test: add box.lib test Cyrill Gorcunov via Tarantool-patches 2021-04-08 18:53 ` Cyrill Gorcunov via Tarantool-patches 2021-04-11 15:43 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-11 21:56 ` Cyrill Gorcunov via Tarantool-patches 2021-04-11 22:36 ` Cyrill Gorcunov via Tarantool-patches 2021-04-12 22:08 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-13 7:10 ` Cyrill Gorcunov via Tarantool-patches 2021-04-13 21:53 ` [Tarantool-patches] [PATCH v21 0/6] box: implement box.lib Lua module Vladislav Shpilevoy via Tarantool-patches 2021-04-14 8:07 ` Kirill Yukhin 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=YHN6SEB4oD8zb9iq@grain \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v21 5/6] box: implement box.lib module' \ /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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox