Tarantool development patches archive
 help / color / mirror / Atom feed
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>,
	Mons Anderson <v.perepelitsa@corp.mail.ru>
Subject: Re: [Tarantool-patches] [PATCH v15 07/11] module_cache: use references as a main usage counter
Date: Mon, 8 Feb 2021 14:54:50 +0300	[thread overview]
Message-ID: <20210208115450.GM2172@grain> (raw)
In-Reply-To: <f848b33a-90a3-037e-2492-8e23c7042a4e@tarantool.org>

On Sun, Feb 07, 2021 at 06:20:34PM +0100, Vladislav Shpilevoy wrote:
> 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.

This gonna be a way more longer than zapping slash. But if you
prefer this way, sure thing.

> >  
> > -	module_gc(old);
> > +	module_set_orphan(old);
> > +	module_unref(old);
> > +
> > +	/* From explicit load above */
> > +	module_unref(new);
> 
> 2. Where is the explicit ref?

A couple of lines above

	struct module *new = module_load(package, package_end);
	if (new == NULL)
		return -1;

The thing is that box.schema.func doesn't use module_load at all
which takes first reference, instead it uses symols as an origin
for counters, thus we need to decrease the conter here because
when box.schema.func close last symbol nobody gonna call module_unload
and module will hang in memory forever. Probably I should write
more verbose comment here.

	Cyrill

  reply	other threads:[~2021-02-08 11:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-05 18:54 [Tarantool-patches] [PATCH v15 00/11] box: implement cmod Lua module Cyrill Gorcunov via Tarantool-patches
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 01/11] box/func: factor out c function entry structure Cyrill Gorcunov via Tarantool-patches
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 02/11] module_cache: move module handling into own subsystem Cyrill Gorcunov via Tarantool-patches
2021-02-07 17:20   ` Vladislav Shpilevoy via Tarantool-patches
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 03/11] module_cache: direct update a cache value on reload Cyrill Gorcunov via Tarantool-patches
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 04/11] module_cache: rename calls to ref in module structure Cyrill Gorcunov via Tarantool-patches
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 05/11] module_cache: add comment about weird resolving Cyrill Gorcunov via Tarantool-patches
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 06/11] module_cache: module_reload - drop redundant parameter Cyrill Gorcunov via Tarantool-patches
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 07/11] module_cache: use references as a main usage counter Cyrill Gorcunov via Tarantool-patches
2021-02-07 17:20   ` Vladislav Shpilevoy via Tarantool-patches
2021-02-08 11:54     ` Cyrill Gorcunov via Tarantool-patches [this message]
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 08/11] module_cache: make module to carry hash it belongs to Cyrill Gorcunov via Tarantool-patches
2021-02-07 17:20   ` Vladislav Shpilevoy via Tarantool-patches
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 09/11] module_cache: use own hash for box.schema.func requests Cyrill Gorcunov via Tarantool-patches
2021-02-07 17:20   ` Vladislav Shpilevoy via Tarantool-patches
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 10/11] box/cmod: implement cmod Lua module Cyrill Gorcunov via Tarantool-patches
2021-02-07 17:20   ` Vladislav Shpilevoy via Tarantool-patches
2021-02-05 18:54 ` [Tarantool-patches] [PATCH v15 11/11] test: box/cfunc -- add cmod test Cyrill Gorcunov via Tarantool-patches
2021-02-07 17:20   ` Vladislav Shpilevoy via Tarantool-patches
2021-02-07 17:21     ` Vladislav Shpilevoy via Tarantool-patches
2021-02-06 17:55 ` [Tarantool-patches] [PATCH v15 00/11] box: implement cmod Lua module Vladislav Shpilevoy 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=20210208115450.GM2172@grain \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=v.perepelitsa@corp.mail.ru \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v15 07/11] module_cache: use references as a main usage counter' \
    /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