From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 91F2D64676; Fri, 5 Feb 2021 21:56:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 91F2D64676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612551401; bh=TYGQLg6lGK09lTelkG7Q0fgfrikkOI1prAAeQAWP+Fk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=W9xdZi8YSNs2m6gRDTIP6E96W6HDCye86EaeXS0do1qZS8NmGBDeo3GBTsAOH11mN 6qBZMPY6nRyrq73jfLrw1B4ucrtYz88435txhNO37dpl1TyUOZ2arabMXbgLHRfo1t IPoVsVZeojT91HS/2fimRhKDOiVdfFxf9LWWvXy0= Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 0440A64676 for ; Fri, 5 Feb 2021 21:55:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0440A64676 Received: by mail-lj1-f169.google.com with SMTP id v15so8933886ljk.13 for ; Fri, 05 Feb 2021 10:55:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eewXZAVTy3AFf9gWM6IO5RR92P3zzQ2rppfuY3T0RdA=; b=ocftwBy2UYl+F74n/VYBoIPc7DZzr6tA/8Ra5rDJscIQWYWUXZMW1JdtG+54+fwrGB tXPiRqKLH9WWpmN3yfUhDM71o5PnYEIcjZSiJJo1Hs1CqY/w6/PoTEqjJvnjvC9q4Tk5 mFN8rupsBIl7aGByc9pDCmww6LOByXOT7t/sBAjXV5cHr3EmhVOUQ+0F1+YfYVi2UW7e FI1BUOcbwWtPWi6oxws6hgogY/mdZyCZ17kxdBJwaqNVG/pc52mfwm5aKE0fzQ3dq7b8 7iA8RmD5M1LJDdFPpePA2ge3u/4Zcl5y3Ol0oSG/s81NjX52KNPdb1qTcJ1IJf4NCPJD nibw== X-Gm-Message-State: AOAM532TIPYr6vdwPP+3H7QExJmEQhBhjf71WhThmY49FPTYxZk9uU3O j3O1adbmfuSM3kK0RuSGdJTWug6bKyM= X-Google-Smtp-Source: ABdhPJxIa9QLTVAshWufk/GQBsCmZ3MzW+bsEEKoA4Ef0Mr3sxNC9Dn/qw9cXPIEZ6F194wEXsYzBQ== X-Received: by 2002:a2e:7605:: with SMTP id r5mr3310394ljc.299.1612551326667; Fri, 05 Feb 2021 10:55:26 -0800 (PST) Received: from grain.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id r5sm1128899ljc.81.2021.02.05.10.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 10:55:25 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 82D5A560273; Fri, 5 Feb 2021 21:54:37 +0300 (MSK) To: tml Date: Fri, 5 Feb 2021 21:54:29 +0300 Message-Id: <20210205185436.638894-5-gorcunov@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205185436.638894-1-gorcunov@gmail.com> References: <20210205185436.638894-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v15 04/11] module_cache: rename calls to ref in module structure X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Mons Anderson , Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" We will use this field not only to count a number of active calls to the module but to prevent the module from disappear when it get loaded via "cmod" interface (will be implemented in next patches). Same time make it 64 bit long since there might be a number of such references size_t didn't prevent from numeric overflow. Part-of #4642 Signed-off-by: Cyrill Gorcunov --- src/box/module_cache.c | 8 ++++---- src/box/module_cache.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/box/module_cache.c b/src/box/module_cache.c index 90d18fa73..e8a510d26 100644 --- a/src/box/module_cache.c +++ b/src/box/module_cache.c @@ -230,7 +230,7 @@ module_load(const char *package, const char *package_end) memcpy(module->package, package, package_len); module->package[package_len] = 0; rlist_create(&module->funcs_list); - module->calls = 0; + module->refs = 0; const char *tmpdir = getenv("TMPDIR"); if (tmpdir == NULL) @@ -328,7 +328,7 @@ module_delete(struct module *module) static void module_gc(struct module *module) { - if (rlist_empty(&module->funcs_list) && module->calls == 0) + if (rlist_empty(&module->funcs_list) && module->refs == 0) module_delete(module); } @@ -442,9 +442,9 @@ module_sym_call(struct module_sym *mod_sym, struct port *args, */ struct module *module = mod_sym->module; assert(module != NULL); - ++module->calls; + ++module->refs; int rc = mod_sym->addr(&ctx, data, data + data_sz); - --module->calls; + --module->refs; module_gc(module); region_truncate(region, region_svp); diff --git a/src/box/module_cache.h b/src/box/module_cache.h index 0f5d2b64a..0d56aea92 100644 --- a/src/box/module_cache.h +++ b/src/box/module_cache.h @@ -41,9 +41,9 @@ struct module { */ struct rlist funcs_list; /** - * Count of active calls. + * Count of active references to the module. */ - size_t calls; + int64_t refs; /** * Module's package name. */ -- 2.29.2