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 BDC1F70358; Wed, 3 Feb 2021 01:14:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BDC1F70358 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612304054; bh=QQtmjZISudVU3XYJt1hTTEiYCJ5hg6E6oZPIABNpkqc=; 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=LtJJ5WEgPaFu+D6WiO7qpiNohLnaT2UKYBMa6+CrCg9rEQIFXY9V7Us32yezxbZnI +dgkK30bCtoi2TwnyYWl/0DKIvvGxfHK0WBFQDbIMdazR7JbsuIdh8rb49t4aJYwzx 3qLE74Tl8vhRiSs4edTYcbelzpLakMC1ZTfU4LIc= Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 E4D7270358 for ; Wed, 3 Feb 2021 01:13:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E4D7270358 Received: by mail-lj1-f172.google.com with SMTP id e18so25887143lja.12 for ; Tue, 02 Feb 2021 14:13:00 -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=FG+7C8SUO6W6pndzPgL+h9ogPg2W1KkPw7X5dPk6rZ4=; b=jDJnctUZaa7ydoJq0FFfR55I+UrKRVKErpPpR5xm8+FaFA5NWGiqfZYJ0ntiG7+4p1 HWY9qbDueimTq8/UrTG70+PZgMuFDFLdZHEctLdvlSDDUV5dj6T/GWn9M+YVY63YvVcU aNo2XjnB+eW52B+JoRWVMn/uLs2t/+o1i1BMFA7az/Qg+Pya5SyIDLercEwbQAGXY4Cv xvI6+sAZm/UrSFnnSA/mh93LjcyyVLJIjPLfgX/UOilnqepmnr2HlHhpujWCz8eU1ukH M5nZp4YLVT7zwSMXna7Gdes+QXcHIlS1wLwcv8u1nesR1cEQfoFzf7C2KhfeiIr7+boe +3uw== X-Gm-Message-State: AOAM531QdynuI4OIV3/RNtHxiycV3mgZbIXDunTb7wudSXvD8SGW0px7 BGNBcyond/rQL3jV3xXPisoJKyt1nD4= X-Google-Smtp-Source: ABdhPJxd6Rjyhudv5uKKcL+8QJGoSJx18ubLJ7OgKQK5FbVRsCCplWoXmEZic3nCTJw6E5arS12BEg== X-Received: by 2002:a2e:9d87:: with SMTP id c7mr1953631ljj.80.1612303979828; Tue, 02 Feb 2021 14:12:59 -0800 (PST) Received: from grain.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id o14sm28339lfi.257.2021.02.02.14.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 14:12:58 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 8C8C356026E; Wed, 3 Feb 2021 01:12:08 +0300 (MSK) To: tml Date: Wed, 3 Feb 2021 01:11:59 +0300 Message-Id: <20210202221207.383101-5-gorcunov@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210202221207.383101-1-gorcunov@gmail.com> References: <20210202221207.383101-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v14 04/12] 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: 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 b3bfb4963..9e5670c03 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