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 4/4] box/func: simplify func_c_call Date: Wed, 17 Feb 2021 23:15:21 +0300 [thread overview] Message-ID: <20210217201521.436951-5-gorcunov@gmail.com> (raw) In-Reply-To: <20210217201521.436951-1-gorcunov@gmail.com> We can reuse cmod_call to eliminate code duplication. Moreover since cmod_call keeps a reference to cmod instance while executing a call, we no longer need module::calls counter (the module won't be unloaded unti execution is complete). Part-of #4642 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> --- src/box/func.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/src/box/func.c b/src/box/func.c index 5757f7c25..942c7c3c1 100644 --- a/src/box/func.c +++ b/src/box/func.c @@ -200,7 +200,6 @@ module_new(struct cmod *cmod) } rlist_create(&module->funcs); - module->calls = 0; module->cmod = cmod; return module; @@ -254,7 +253,7 @@ module_delete(struct module *module) static void module_gc(struct module *module) { - if (rlist_empty(&module->funcs) && module->calls == 0) + if (rlist_empty(&module->funcs)) module_delete(module); } @@ -513,32 +512,9 @@ func_c_call(struct func *base, struct port *args, struct port *ret) return -1; } - struct region *region = &fiber()->gc; - size_t region_svp = region_used(region); - uint32_t data_sz; - const char *data = port_get_msgpack(args, &data_sz); - if (data == NULL) - return -1; - - port_c_create(ret); - box_function_ctx_t ctx = { ret }; - - /* Module can be changed after function reload. */ struct module *module = func->module; - assert(module != NULL); - ++module->calls; - int rc = func->func(&ctx, data, data + data_sz); - --module->calls; + int rc = cmod_call(module->cmod, func->func, args, ret); module_gc(module); - region_truncate(region, region_svp); - if (rc != 0) { - if (diag_last_error(&fiber()->diag) == NULL) { - /* Stored procedure forget to set diag */ - diag_set(ClientError, ER_PROC_C, "unknown error"); - } - port_destroy(ret); - return -1; - } return rc; } -- 2.29.2
prev parent reply other threads:[~2021-02-17 20:17 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 ` [Tarantool-patches] [PATCH 2/4] box/func: update module cache in one pass Cyrill Gorcunov via Tarantool-patches 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 ` Cyrill Gorcunov via Tarantool-patches [this message]
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-5-gorcunov@gmail.com \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 4/4] box/func: simplify func_c_call' \ /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